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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

jai9

Active Member
Joined
Jul 20, 2012
Messages
325
Hi,

Try

If Target.Value = "Military" Then

instead of your original line.

Jai
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,951
Messages
5,834,540
Members
430,295
Latest member
amdis

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