Hi Excel users.
I have these two macros that will hide/unhide blank cell in a table.
What I am tryng to do is combine them so the user only needs to click one button and not two.
I have tried with an if statatement, but I get an error message.
Any suggestions?
Thanks.
I have these two macros that will hide/unhide blank cell in a table.
What I am tryng to do is combine them so the user only needs to click one button and not two.
Code:
Sub Hide_blank_rows()
ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=2, Criteria1:= _
"<>"
End Sub
Sub Show_blank_rows()
ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=2
End Sub
I have tried with an if statatement, but I get an error message.
Code:
Sub Hide_show_blank_rows()
if ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=2 then
ActiveSheet.Shapes("Button 2").TextFrame.Characters.Text = "Unhide"
ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=2, Criteria1:= _
"<>"
Else
ActiveSheet.Shapes("Button 2").TextFrame.Characters.Text = "Hide"
ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=2
End If
End Sub
Any suggestions?
Thanks.