Hide Rows Based on Values of Two Different Cells

JeremyEBS

New Member
Joined
Sep 10, 2014
Messages
3
Hi all, I have been trying to find an answer to this question and can't seem to get my VBA code to work properly. I have two separate Active X check boxes controlling the TRUE/FALSE statement for two distinct cells. What I want the VBA code to do is to hide the row when both values controlled by the checkbox equal False. In simpler terms IF A52 = False & T52 = False, Then hide row 52. I would like this to be completed for rows 52-71 and rows 131-150. The location of the TRUE/FALSE statement remains in the same A and T column for each respective row. I hope this makes sense and any help is vastly appreciated!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Code:
Dim i as long
For i = 52 to 71
If Range("A" & i)= False and Range("T" & i) = False then
Range("A" & i).entirerow.hidden= true
End if
Next i

for i = 131 to 150
If Range("A" & i)= False and Range("T" & i) = False then
Range("A" & i).entirerow.hidden= true
End if
Next i

This assumes that the True False are booleans and not strings. If strings, then they must be encased in quotation marks in the code.
 
Upvote 0
Code:
Dim i as long
For i = 52 to 71
If Range("A" & i)= False and Range("T" & i) = False then
Range("A" & i).entirerow.hidden= true
End if
Next i

for i = 131 to 150
If Range("A" & i)= False and Range("T" & i) = False then
Range("A" & i).entirerow.hidden= true
End if
Next i

This assumes that the True False are booleans and not strings. If strings, then they must be encased in quotation marks in the code.

Great! I was able to make the code work! However, what would need to be added to the code in order to have the rows that were hidden to reappear if one of the cell values changes to True? would it be as simple as the same coding, but change true to false and false to true and command be entirerow.unhidden?
 
Upvote 0
Great! I was able to make the code work! However, what would need to be added to the code in order to have the rows that were hidden to reappear if one of the cell values changes to True? would it be as simple as the same coding, but change true to false and false to true and command be entirerow.unhidden? (this doesn't exist, so what is the proper code to unhide?)
 
Upvote 0
Code:
Range("A" & i).entirerow.hidden= false

But, if the row is hidden, you would have to unhide it first to make any changes. So you probably want to just use the same code to unhide all with the code above changing the status so that you can make changes to the data and then run the code again to hide.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,700
Messages
6,126,301
Members
449,308
Latest member
VerifiedBleachersAttendee

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