View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
marjattanb marjattanb is offline
external usenet poster
 
Posts: 7
Default macro to hide empty rows

Hi,

thanks again (do u ever sleep??)

Now it gets stuck with SYNTAX ERROR with this:
lr = Cells.Find("*", Cells(Rows.Count, Columns.Count), , , xlByRows,
xlPrevious).Row

And I am stuck again..

"Don Guillett" wrote:

Try this

Sub hideemptyrows()
lr = Cells.Find("*", Cells(Rows.Count, Columns.Count), , , xlByRows,
xlPrevious).Row
For i = 1 To lr
lc = Cells(i, Columns.Count).End(xlToLeft).Column
For j = 1 To lc
If Application.CountA(Rows(i)) < 1 Or _
Cells(i, j).HasFormula And Cells(i, j) = "" Then
Rows(i).Hidden = True
End If
Next j
Next i
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rick Rothstein" wrote in message
...
I don't get that macro to work if there are cells containing formulas that
evaluate to the empty string.

--
Rick (MVP - Excel)


"Don Guillett" wrote in message
...

You may desire to use a macro that looks at the number of hits

Sub hideemptyrows()
For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If Application.CountA(Rows(i)) < 1 Then Rows(i).Hidden = True
Next i
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"marjattanb" wrote in message
...
Hello,

I am trying to hide empty rows in a named range (A5:BU1111) where all
"empty" rows however do have a formula in several columns (where the
value is
"").

The only way I have managed is to create a dummy column (which I have
named
"ROW_SHRINK_AREA", which creates some values which indicate that the row
in
question is not empty. Then I use the macro:

Sub MakeEmptyRowsGoAway()
Application.Goto Reference:="ROW_SHRINK_COLUMN"
For Each R In Application.Intersect(ActiveSheet.UsedRange, _
ActiveSheet.Range("ROW_SHRINK_COLUMN")).Cells
varValue = R.Value
If IsNumeric(varValue) Then
If varValue = 0 Then
R.EntireRow.Hidden = True
End If
End If
Next R
End Sub

Would someone please advise me a faster method?