Macro Help

tbourne

New Member
Joined
Oct 5, 2011
Messages
1
Hey Guys,

I need help hiding rows based on a cells value....

I need cells 14 - 47 hidden until the button that you create has been pressed.
once the button has been pressed I need the following to happen:
Show Rows 19:23 and 29:33 when the button is pressed (regardless of the value)
If Cell "I1" is OR greater then 2 show rows 14:18 and
If Cell "I1 is or greater than 22 days then show rows 24:28
If Cell "I1" is or greater than 15 days show rows 34:46
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try:
Code:
Sub hid()
Rows("14:47").Hidden = True
Rows("19:23").Hidden = False
Rows("29:33").Hidden = False
Select Case Range("I1").Value
    Case Is >= 15
        Rows("34:46").Hidden = False
    Case Is >= 22
        Rows("24:28").Hidden = False
    Case Is >= 2
        Rows("14:18").Hidden = False
End Select
End Sub
 
Upvote 0
Code:
    Case Is >= 15
        Rows("34:46").Hidden = False
    Case Is >= 22
        Rows("24:28").Hidden = False
    Case Is >= 2
        Rows("14:18").Hidden = False

The CASE order need to be changed. You need to test >=22 before you test if >= 15 otherwise the second Case ( >=22) will never get selected because all values that are greater than 22 are also greater than 15. So the first case (>=15) will evaluate true before the second case has a chance to evaluate.

The case order should be switched to this...
Code:
    Case Is >= 22
        Rows("24:28").Hidden = False
    Case Is >= 15
        Rows("34:46").Hidden = False
    Case Is >= 2
        Rows("14:18").Hidden = False
 
Upvote 0

Forum statistics

Threads
1,224,608
Messages
6,179,872
Members
452,949
Latest member
Dupuhini

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