JackDanIce
Well-known Member
- Joined
- Feb 3, 2010
- Messages
- 9,922
- Office Version
- 365
- Platform
- Windows
Hi,
I currently filter my data and then use this bit of code to remove the filtered rows, whilst keeping the header:
However, I'm now trying to change this to (ignore the defined range, purely for test purposes):
Line in red is where it fails, I believe my Resize use is not correct, but unsure of what correct sytnax here should be.
Can anyone correct or suggest what to use in combination with SpecialCells(xlCellTypeVisible) so that the header is kept but the remainder of the visible rows are deleted?
Thanks,
Jack
I currently filter my data and then use this bit of code to remove the filtered rows, whilst keeping the header:
Rich (BB code):
With ActiveSheet
.UsedRange.Offset(1, 0).Resize(ActiveSheet.UsedRange.Rows.Count - 1).Rows.Delete
.AutoFilterMode = False
End With
Rich (BB code):
With Range("A1:C5")
.AutoFilter
.AutoFilter field:=2, Criteria1:="1"
.SpecialCells(xlCellTypeVisible).Offset(1, 0).Resize(.Rows.Count - 1).Rows.Delete
End With
Can anyone correct or suggest what to use in combination with SpecialCells(xlCellTypeVisible) so that the header is kept but the remainder of the visible rows are deleted?
Thanks,
Jack