andrismeister
New Member
- Joined
- Apr 10, 2013
- Messages
- 5
Dear all,
I'm kind of new here - and to excel macros as well -, and eventhough I was trying to look up solution here on mrexcel forums, I couldn't find an appropriate adn that's why I've opened a new thread for it.
So the case is:
I have a sheet with 12 rows which I want to work with.
I have made a dropdown validation list of four values (A, B, C, and D) which works fine.
What I would like to do is:
- when I select a value from the dropdown list, I'd like a macro to run and hide 9 rows from the 12, but leave the 3 rows to be unhidden.
I have already written a macro, which does it's job, the only problem is that I was only able to find a solution to trigger it by clicking on a button after selecting the desired value from the dropdown list.
But instead of triggering it by clicking on the button, I'd like the macro to run automatically when the dropdown list cell has changed.
My macro so far is:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Target.Worksheet.Range("A8")) Is Nothing Then Macro
Sub selectsequencemodel()
Rows("10:21").EntireRow.Hidden = False
If Range("A8") = "A" Then
Rows("10:12").EntireRow.Hidden = False
Rows("13:21").EntireRow.Hidden = True
End If
If Range("A8") = "B" Then
Rows("10:12").EntireRow.Hidden = True
Rows("16:21").EntireRow.Hidden = True
End If
If Range("A8") = "C" Then
Rows("10:15").EntireRow.Hidden = True
Rows("19:21").EntireRow.Hidden = True
End If
If Range("A8") = "D" Then
Rows("10:18").EntireRow.Hidden = True
End If
End Sub
cell A8 is the place of the dropdown list.
If you need additional information, let me know.
Thank you for your help in advance.
Regards,
Andrew
I'm kind of new here - and to excel macros as well -, and eventhough I was trying to look up solution here on mrexcel forums, I couldn't find an appropriate adn that's why I've opened a new thread for it.
So the case is:
I have a sheet with 12 rows which I want to work with.
I have made a dropdown validation list of four values (A, B, C, and D) which works fine.
What I would like to do is:
- when I select a value from the dropdown list, I'd like a macro to run and hide 9 rows from the 12, but leave the 3 rows to be unhidden.
I have already written a macro, which does it's job, the only problem is that I was only able to find a solution to trigger it by clicking on a button after selecting the desired value from the dropdown list.
But instead of triggering it by clicking on the button, I'd like the macro to run automatically when the dropdown list cell has changed.
My macro so far is:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Target.Worksheet.Range("A8")) Is Nothing Then Macro
Sub selectsequencemodel()
Rows("10:21").EntireRow.Hidden = False
If Range("A8") = "A" Then
Rows("10:12").EntireRow.Hidden = False
Rows("13:21").EntireRow.Hidden = True
End If
If Range("A8") = "B" Then
Rows("10:12").EntireRow.Hidden = True
Rows("16:21").EntireRow.Hidden = True
End If
If Range("A8") = "C" Then
Rows("10:15").EntireRow.Hidden = True
Rows("19:21").EntireRow.Hidden = True
End If
If Range("A8") = "D" Then
Rows("10:18").EntireRow.Hidden = True
End If
End Sub
cell A8 is the place of the dropdown list.
If you need additional information, let me know.
Thank you for your help in advance.
Regards,
Andrew
Last edited: