Hide row(s) based on drop down selection

G

Guest

I need to hide rows based on a drop down selection. Example: if d5 (drop down
cell) = refund, then hide rows 33 through 36, else hide row 25.

For the life of me my macro didn't work.

Thanks
 
R

Ron de Bruin

You can use the change event in the sheet module

Try this one

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("D5"), Target) Is Nothing Then
Range("A25,A33:A36").EntireRow.Hidden = False
If Target.Value = "refund" Then
Range("A33:A36").EntireRow.Hidden = True
Else
Range("A25").EntireRow.Hidden = True
End If
End If
End Sub
 
G

Guest

I copied and pasted your info, made changes to suit my ranges. But when I
select things from the drop down - nothing happens.

Where did I go wrong?
 
R

Ron de Bruin

Hi Maritza

Do you copy it in the correct sheet module ?
Do you use a Data validation dropdown list in D5 ?

Do you use Excel 97 ?



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


Maritza said:
I copied and pasted your info, made changes to suit my ranges. But when I
select things from the drop down - nothing happens.

Where did I go wrong?
 
G

Guest

I'm unsure whether it's in the correct sheet module.
Yes, I did use data validation for the dropdown list in D5.
I'm using Excel 2003
 
R

Ron de Bruin

Hi Maritza
Right click the sheet tab and choose view code
Paste the code there
Alt q to go back to Excel

Now change the dropdown


Excel 2003 is OK
Change event is not working in a Data validation cell in Excel 97



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


Maritza said:
I'm unsure whether it's in the correct sheet module.
Yes, I did use data validation for the dropdown list in D5.
I'm using Excel 2003
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top