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.
 

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

jai9

Active Member
Joined
Jul 20, 2012
Messages
325
Hi,

Try

If Target.Value = "Military" Then

instead of your original line.

Jai
 

Watch MrExcel Video

Forum statistics

Threads
1,123,259
Messages
5,600,573
Members
414,389
Latest member
MarkElla

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