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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,308
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,308
Office Version
365
Platform
Windows
thanks for the feedback (y)
 

Watch MrExcel Video

Forum statistics

Threads
1,101,946
Messages
5,483,831
Members
407,415
Latest member
Anton1999

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top