Hello,
As the title suggests I'm trying to copy a range of filtered cells. The source has a lot more than 5 rows but of these filtered cells I'm only trying to copy the first 5. This is the code I've been using so far:
I've added the resize property for ensuring it's not longer than 5 rows and the offset property so the header is excluded.
My problem is that this code copies the whole table but I only want to copy the first five in column "B" and only 3 rows are copied.
Best Regards,
DenialDan.
As the title suggests I'm trying to copy a range of filtered cells. The source has a lot more than 5 rows but of these filtered cells I'm only trying to copy the first 5. This is the code I've been using so far:
Code:
Sub Top5()
Dim CopyRange As Range
Sheets(5).Range("B3").AutoFilter Field:=1, Criteria1:="2017-Q3"
Sheets(7).Range("B3").AutoFilter Field:=1, Criteria1:="2017-Q3"
On Error Resume Next
With Sheets(5).AutoFilter.Range
Set CopyRange = .Offset(1, 0).Resize(5).SpecialCells(xlCellTypeVisible)
End With
CopyRange.Copy Sheets("FC").Range("C30:C34")
End Sub
I've added the resize property for ensuring it's not longer than 5 rows and the offset property so the header is excluded.
My problem is that this code copies the whole table but I only want to copy the first five in column "B" and only 3 rows are copied.
Best Regards,
DenialDan.