Monday, August 29, 2022

How to copy filtered cells in excel

 

  1. Select the cells that you want to copy For more information, see Select cells, ranges, rows, or columns on a worksheet. ...
  2. Click Home > Find & Select, and pick Go To Special.
  3. Click Visible cells only > OK.
  4. Click Copy (or press Ctrl+C).
or we can copy by programmatically
Sub CopyFilteredData()
Dim r As Integer, KIA As String, ws As Worksheet
Set ws = ActiveSheet
ws.Range("A1:K1").AutoFilter
r = 1
Do
    r = r + 1
    KIA = ws.Range("H" & r).Value
    On Error Resume Next
    If Sheets(KIA) Is Nothing Then
        ws.Range("A1:K1").AutoFilter Field:=8, Criteria1:=KIA
        ws.Range("A1").CurrentRegion.SpecialCells(xlCellTypeVisible).Copy
        Sheets.Add.Name = KIA
        Sheets(KIA).Paste
        ws.ShowAllData
    End If
Loop While ws.Range("A" & r + 1).Value <> ""
End Sub
        

No comments:

Post a Comment