Action from list selection

M

Maze

All:

I have a number of options in a drop down list and based on the selection
(2, 3, 4 etc) need to unhide rows. So if user selects 4, need to unhide 4
rows, if they select 0, no rows should show. What's the best way to do this?
Thank you.
 
P

Patrick Molloy

I assume you have a number of rows hidden? after all in a sheet you can't
show no rows can you?

something like

Private Sub ComboBox1_Change()
Range("A10:A20").EntireRow.Hidden = True
Range("A10").Resize(ComboBox1.Value).EntireRow.Hidden = False
End Sub

this uses the activex combobox, so the code should be on the sheet's code
page - to get there, right click the sheet tab & select View Code
 
M

Maze

Patrick - thanks for replying. Maybe I wasn't clear enough with my question
but I was able to figure some code out that would work, the only problem is
it only works one directional. (Example: if user selects 4, then 5, it
works. If they select 2 it won't go back). Any thoughts? See code below.

Sub DropDown44_Change()
'IBDA selection

If range("v1").Value = "2" Then
Rows("16:19").Hidden = False
ElseIf range("v1").Value = "3" Then
Rows("16:23").Hidden = False
ElseIf range("v1").Value = "4" Then
Rows("16:27").Hidden = False
ElseIf range("v1").Value = "5" Then
Rows("16:31").Hidden = False
ElseIf range("v1").Value = "6" Then
Rows("16:35").Hidden = False

Else
Rows("16:60").Hidden = True

End If
End Sub
 

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