Hide and unhide rows based on values

Satheesh9012

New Member
Joined
Mar 19, 2021
Messages
41
Office Version
  1. 365
Platform
  1. Windows
Hi

I need help for one of the codes which is working fine in one form in an excel sheet but not in others, i am trying to hide/unhide certain rows in the sheet based on Yes or no values, if it is Yes a row should be hidden if it is no a row should be hidden so it is working fine in the first form in the excel but when i tried to replicate it in the second form in the same excel sheet in a different row it does not work nor throws an error,

below code i used, i have the range and row changing in 5 other different places in the same sheet

If Range("C32").Value = "Yes" Then
Rows("34:34").EntireRow.Hidden = True
ElseIf Range("C32").Value = "No" Then
Rows("33:33").EntireRow.Hidden = True
Rows("34:34").EntireRow.Hidden = False
End If
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
What do you mean by “a form in an excel sheet”?
Anyway, reading Op made me wonder if the Yes/No cell is C32 also in the target sheet but is it?
 
Upvote 0
What do you mean by “a form in an excel sheet”?
Anyway, reading Op made me wonder if the Yes/No cell is C32 also in the target sheet but is it?
Yes in a excel sheet there are 6 cells requesting yes or no, so for example if it is yes, a row(15) will be be hidden and if no row(16) will be hidden and unhide row(15), similar way there are 6 cells contacting the same process, actually it worked for me in one of the cell in the same sheet when i am trying to replicate the same code in different cell it does not work
 
Upvote 0
So what are those cells?

This is probably because you have incorrect cell references in the code.
c13,c32,c51,c70,C89,C108, are the cells which have yes or no values to have user input, once they select these cells the rows should hide based on the rows defined
 
Upvote 0
c13,c32,c51,c70,C89,C108, are the cells which have yes or no values to have user input, once they select these cells the rows should hide based on the rows defined, so the first one actly works in c13, but not in any other cells
 
Upvote 0
I became confused with this:
Your quote post 1"
if it is Yes a row should be hidden if it is no a row should be hidden
So in either case the row should be hidden??
 
Upvote 0
I became confused with this:
Your quote post 1"
if it is Yes a row should be hidden if it is no a row should be hidden
So in either case the row should be hidden??
apologies if my request was confusing to understand, so as you rightly told if the value is "yes" in the cell (C32), row 34 should be hidden and row 35 should be visible as default, if (C32) is "no" row 35 should be hidden and unhide row 34, like wise the yes or no values are available in the cell ,(c51,c70,C89,C108,), corresponding rows are also required to hide and unhide based on cell value yes or no
 
Upvote 0
apologies if my request was confusing to understand, so as you rightly told if the value is "yes" in the cell (C32), row 34 should be hidden and row 35 should be visible as default, if (C32) is "no" row 35 should be hidden and unhide row 34, like wise the yes or no values are available in the cell ,(c51,c70,C89,C108,), corresponding rows are also required to hide and unhide based on cell value yes or no
is it clear now or still need further explanation?
 
Upvote 0

Forum statistics

Threads
1,215,125
Messages
6,123,193
Members
449,090
Latest member
bes000

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