View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default if cell empty hide row macro?

You would need a toggle button for that.

If you want to have the command button toggle the rows (each time it is
clicked), you can do

Private Sub CommandButton1_Click()
Dim rng As Range, rng1 As Range
On Error Resume Next
Set rng = Range("AD:AD").SpecialCells(xlBlanks)
Set rng1 = Range("AD:AD").SpecialCells(xlVisible)
On Error GoTo 0
Debug.Print rng.Address
Debug.Print rng1.Address
If Not rng Is Nothing Then
If rng1.Areas.Count = 1 Then
rng.EntireRow.Hidden = True
Else
rng.EntireRow.Hidden = False
End If
End If
End Sub

--
Regards,
Tom Ogilvy


"Todd" wrote in message
...
Thank you Tom, I have this set to a command button and it works

wonderfully. Another question about this though. I want to have the button
hide when clicked and unhide if unselected too. How can somethng like this
be done?

Again, Thanks

Todd





"Tom Ogilvy" wrote:

Range("AD:AD").SpecialCells(xlBlanks).Entirerow.Hi dden = True

--
Regards,
Tom Ogilvy

"Todd" wrote in message
...
Hi, I need a macro that will hide rows if a cell in column AD is

empty.

Can anyone help me?


Thanks

Todd