Autofilter past blank rows

  • Thread starter Thread starter lunker55
  • Start date Start date
L

lunker55

I have a macro that puts two blank rows between every row that has a
different day. The problem is the autofilter does not see anything past the
blank rows.
It worked on my old file, and I can't remember how I did it. I'm sure
someone on this group showed me how to do it the first time.
Thanks,
Joe
 
You must select the entire list before you go to Data/Filter/AutoFilter.

BTW, to eliminate problems like this, I would delete the blank rows and have
your macro increase the row height when the date changes. The visual effect is
the same, problems like the current one are eliminated.
 
Thank you thank you thank you. So simple!
I also like your idea of changing the row height at every date change.
But I'm not sure I like having some rows with data having different row
heights.
Joe
 
This uses dates in column A:

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long

Set wks = Worksheets("sheet1")
With wks
.UsedRange.Rows.AutoFit
FirstRow = 2 'headers in 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = LastRow To FirstRow Step -1
If .Cells(iRow, "A").Value = .Cells(iRow - 1, "A").Value Then
'do nothing
Else
.Rows(iRow).RowHeight = .Rows(iRow).RowHeight * 2
End If
Next iRow
End With
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Thanks Dave. I'll give it a try.
Joe

Dave Peterson said:
This uses dates in column A:

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long

Set wks = Worksheets("sheet1")
With wks
.UsedRange.Rows.AutoFit
FirstRow = 2 'headers in 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = LastRow To FirstRow Step -1
If .Cells(iRow, "A").Value = .Cells(iRow - 1, "A").Value Then
'do nothing
Else
.Rows(iRow).RowHeight = .Rows(iRow).RowHeight * 2
End If
Next iRow
End With
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top