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!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
try amending these lines

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

[COLOR=#ff0000].Offset(1)[/COLOR].SpecialCells(xlCellTypeVisible).Copy
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top