Macro if cell equals 0
Solved
-
Hello everyone,
I'm currently working on an Excel file and I need your help!
I would like to create a macro that hides a row if a specific cell in that row equals 0.
The row should only be hidden if there is a 0 in the cell.
I had a solution, but it also hides the row when the cell is empty...
Here it is:
If Range ("AB2") = 0 Then
Rows("2:2").Select
Selection.EntireRow.Hidden = True
End If
Thank you for your help
Best regards
Peybernes
I'm currently working on an Excel file and I need your help!
I would like to create a macro that hides a row if a specific cell in that row equals 0.
The row should only be hidden if there is a 0 in the cell.
I had a solution, but it also hides the row when the cell is empty...
Here it is:
If Range ("AB2") = 0 Then
Rows("2:2").Select
Selection.EntireRow.Hidden = True
End If
Thank you for your help
Best regards
Peybernes
1 answer
-
ContributorHello,
You can do it this way while avoiding 'select':If Range("AB2").Value = 0 And Range("AB2").Value <> "" Then Rows(2).EntireRow.Hidden = True
Always zen
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupéry