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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,222,900
Messages
6,168,926
Members
452,227
Latest member
sam1121

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