VBA macro to hide rows based on a selected input

excelhack

New Member
Joined
Feb 17, 2010
Messages
16
I have a file in which I'm working on where I would like to hide a number of rows based on a selcetion from an inbedded drop down menu. The selection I'm concerned about is the fifth selection in a list of five. The macro I'm using is shown below:

Sub HideRows Worksheet_Change(ByVal Target As Range)<o:p></o:p>
If Target.Cells.Count = 1 And Target.Address = "$C$10" Then<o:p></o:p>
<o:p></o:p>
If LCase(Target.Value) = "Military" Then<o:p></o:p>
Rows("13:60").EntireRow.Hidden = True<o:p></o:p>
<o:p> </o:p>
Else<o:p></o:p>
Rows("13:60").EntireRow.Hidden = False<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
End If<o:p></o:p>
End Sub<o:p></o:p>
<o:p> </o:p>
End Sub

When I remove the 2nd statement of "End Sub" i get an error message on the first row when I try to debug it.

I am an absolute novice when it comes to VBA.
 

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.
Hi,

Try

If Target.Value = "Military" Then

instead of your original line.

Jai
 
Upvote 0

Forum statistics

Threads
1,215,507
Messages
6,125,212
Members
449,214
Latest member
mr_ordinaryboy

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