Hide and unhide rows based on values

Satheesh9012

New Member
Joined
Mar 19, 2021
Messages
22
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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

kanadaaa

Active Member
Joined
Dec 29, 2019
Messages
344
Office Version
  1. 365
Platform
  1. Windows
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?
 

Satheesh9012

New Member
Joined
Mar 19, 2021
Messages
22
Office Version
  1. 365
Platform
  1. Windows
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
 

Satheesh9012

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

ADVERTISEMENT

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
 

Satheesh9012

New Member
Joined
Mar 19, 2021
Messages
22
Office Version
  1. 365
Platform
  1. Windows
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
 

Satheesh9012

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

ADVERTISEMENT

Any solution for my query ?
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,563
Office Version
  1. 2013
Platform
  1. Windows
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??
 

Satheesh9012

New Member
Joined
Mar 19, 2021
Messages
22
Office Version
  1. 365
Platform
  1. Windows
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
 

Satheesh9012

New Member
Joined
Mar 19, 2021
Messages
22
Office Version
  1. 365
Platform
  1. Windows
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?
 

Watch MrExcel Video

Forum statistics

Threads
1,129,590
Messages
5,637,279
Members
416,963
Latest member
samfuge

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
Top