Macro not firing when cell value changes

billfinn

Board Regular
Joined
Jun 7, 2018
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
Good morning!
I am trying to get this macro to fire when the value in cell F31 changes. The macro hides and un-hides specific rows based on the value in F31. F31 values are changed by a pull down menu. I'm trying to hide all values not pertaining to the choice made from the pull down regarding roof slope. I did insert the code in the worksheet where the pull down makes the changes. I change the values in F31 and nothing happens. I would greatly appreciate any input or suggestions regarding how to get this working.
Thanks very much for any help you could render
Bill

Code:
Sub HideRows()

Sheets("QUICK QUOTE").Select


Rows.EntireRow.Hidden = False


If F31 = "4:12" Then
    Rows("164:171").EntireRow.Hidden = False
    Rows("173:234").EntireRow.Hidden = True
If F31 = ("5:12") Then
    Rows("173:180").EntireRow.Hidden = False
    Rows("164:172").EntireRow.Hidden = True
    Rows("181:234").EntireRow.Hidden = True
If F31 = ("6:12") Then
    Rows("182:189").EntireRow.Hidden = False
    Rows("164:181").EntireRow.Hidden = True
    Rows("190:234").EntireRow.Hidden = True
If F31 = ("7:12") Then
    Rows("191:198").EntireRow.Hidden = False
    Rows("164:190").EntireRow.Hidden = True
    Rows("199:234").EntireRow.Hidden = True
If F31 = ("8:12") Then
    Rows("200:207").EntireRow.Hidden = False
    Rows("164:199").EntireRow.Hidden = True
    Rows("208:234").EntireRow.Hidden = True
If F31 = ("9:12") Then
    Rows("209:216").EntireRow.Hidden = False
    Rows("164:208").EntireRow.Hidden = True
    Rows("217:234").EntireRow.Hidden = True
If F31 = ("10:12") Then
    Rows("218:225").EntireRow.Hidden = False
    Rows("164:217").EntireRow.Hidden = True
    Rows("226:234").EntireRow.Hidden = True
If F31 = ("12:12") Then
Rows("227:234").EntireRow.Hidden = False
    Rows("164:226").EntireRow.Hidden = True
End If
End Sub
 
Joe4,
I had to write and confess my duh moment of this morning. I made a couple of changes to my workbook and every time I did the 300+ rows that I have hidden would reappear. I would hide them again and then they would reappear a few minutes later. Took me about 15 minutes to figure it out. I went back to this thread and had an Aha! moment. Changed the first row after the sub is declared from
Code:
[COLOR=#333333]Rows.EntireRow.Hidden = False
to [/COLOR]
Code:
[COLOR=#333333]Rows("173:234") .EntireRow.Hidden
. No more issue.
Thanks again for all of your help yesterday
Bill[/COLOR]
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
You are welcome.
Glad you got it all sorted out.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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