Autofilter not hiding first blank cell/row

Jockster

Board Regular
Joined
Jan 16, 2009
Messages
88
The issue I am having with autofilter is that it isn't hiding the first row of a range when the first cell in the filtered column of that range is empty.
Code snippet:

Code:
If Range("G1") > 0 'Then 'competitors' times have been entered
   lastrow = Range("G" & Rows.Count).End(xlUp).Row 'identify the last used row
Set GetRange = Range("A7:H" & lastrow) 'range to filter/copy
        With GetRange
            .AutoFilter
            .AutoFilter Field:=6, Criteria1:="<>"
            .SpecialCells(xlCellTypeVisible).Copy
            Range("BB7").PasteSpecial Paste:=xlPasteValues
            .AutoFilter
        End With
Row 6 contain the headers which should not be copied
Row 7 is the start of the data
Column 6 (F) contains the times (in HH:MM) and is the column I am filtering on.
Cell F6 contains no time therefore it should be hidden by autofilter but it isn't

I have tried varying the range to "A6:H" & lastrow and whilst this did hide the blank row 6, when 'copy' was applied it started it row 9 and ignored 8 which has a value.

Any suggestions welcomed!
 

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,021
Office Version
365
Platform
Windows
try amending these lines

Code:
Set GetRange = Range("A[COLOR=#ff0000]6[/COLOR]:H" & lastrow) 

[COLOR=#ff0000].Offset(1)[/COLOR].SpecialCells(xlCellTypeVisible).Copy
 

Jockster

Board Regular
Joined
Jan 16, 2009
Messages
88
try amending these lines

Code:
Set GetRange = Range("A[COLOR=#ff0000]6[/COLOR]:H" & lastrow) 

[COLOR=#ff0000].Offset(1)[/COLOR].SpecialCells(xlCellTypeVisible).Copy
Thanks so much Yongle, this worked like a charm!

Cheers.
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,021
Office Version
365
Platform
Windows
thanks for the feedback (y)
 

Watch MrExcel Video

Forum statistics

Threads
1,099,134
Messages
5,466,871
Members
406,507
Latest member
donwiss

This Week's Hot Topics

Top