VBA - Hide/Unhide based on IF

fjacruz

New Member
Joined
Feb 15, 2019
Messages
7
Hi

Unfortunately I was not able to perform VBA code correctly (based on onter postings). I'm trying to unhide rows when cell A13 is 1 otherwise rows 15:100 are hidden. The idea behind is basically change some parameters that affect cell A13.

I wrote the code like that:
"
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Range("A13").Value > 0 Then
Range("15:100").EntireRow.Hidden = True
Else
Range("15:100").EntireRow.Hidden = False
End If

End Sub
"

Thanks in advance for your help.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
In what way isn't your code working?
 
Upvote 0
In what way isn't your code working?
I tried to setup a questionnaire. when all asnwers were replied cell A13 returns 1 or 0. When this cell changed, hidden rows remained unchanged (whenever excel workbook opens, range 15:100 is hidden)
 
Upvote 0
Your code will only work if you select another cell, otherwise it will do nothing.
 
Upvote 0
If A13 is a formula, then you would need to use the worksheet_calculate event, but that will run whenever any formula in that sheet is re-calculated
 
Upvote 0
Does the formula in A13 only look at other cells on the same sheet?
If yes are all those cells hard values, or are some formulae?
 
Upvote 0
Does the formula in A13 only look at other cells on the same sheet?
If yes are all those cells hard values, or are some formulae?

A13 comes from A7 A9 and A11 all formulas depending on dropwdown list on C7, C9 and C11.
No hard values on A column. Just in C column
 
Upvote 0
In that case the calculate event is your only real option if you want it to be automatic.
 
Upvote 0

Forum statistics

Threads
1,214,645
Messages
6,120,711
Members
448,984
Latest member
foxpro

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