Unable to unhide row when there is values in a particular cell

Starkers

New Member
Joined
Oct 26, 2021
Messages
14
Office Version
  1. 365
Platform
  1. Windows
I have written the following vba code indicating

- if both C11 and C12 are empty, row 64 would be hidden (it works)
- if there is values in C11 but none C12, row 64 would be unhidden (it works)
- if there is values in both C11 and C12, row 64 would be unhidden (it works)
- if there are values in C12 but none C11, row 64 would be unhidden (it doesn't work)

Is there a way to fix the vba code for the last portion?

VBA Code:
If Range("C11") = "" Or Range("C12") = "" Then
Rows("64").EntireRow.Hidden = True
End If

If Range("C12") <> "" Then
Rows("64").EntireRow.Hidden = False
End If

If Range("C11") <> "" Then
Rows("64").EntireRow.Hidden = False
End If
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Why not just:
VBA Code:
Sub TestHide()

    If Range("C11") = "" And Range("C12") = "" Then
        Rows("64").EntireRow.Hidden = True
    Else
        Rows("64").EntireRow.Hidden = False
    End If
    

End Sub
 
Upvote 0
Or even
VBA Code:
Rows(64).Hidden = (Range("C11") = "" And Range("C12") = "")
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,431
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top