Drop-down lists and macros

  • Thread starter Thread starter Lucy
  • Start date Start date
L

Lucy

Doh! I posted this earlier with my name in the subject field instead of the
topic! Very sorry! No wonder no one replied!



Hello
 
Hi
one idea: If you have your drop-down box (created by 'Data -
Validaion') in cell A1 put the following code in your worksheet module:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
On Error GoTo CleanUp:
With Target
Application.EnableEvents = False
select case .value
case "constellation1"
'code for constellation 1
case "constellation2"
'code for constellation 2
'.....
end select
End With
CleanUp:
Application.EnableEvents = True
End Sub

You may change this to your needs as I do not know which kind of code
is currently invoked if a user clicks on a button
 
Hi.

Your can add a combobox in your worksheet(for example: sheet1),and you can
script vba code like below.

'Here is the vba code for in "Workbook_Open" event to Initialize the
combobox.

Private Sub Workbook_Open()

Sheet1.ComboBox1.AddItem "[the names of individual constellations 1]"
Sheet1.ComboBox1.AddItem "[the names of individual constellations 2]"
Sheet1.ComboBox1.AddItem "[the names of individual constellations 3]"
.....

End Sub

'Here is the vba code for "ComboBox1_Change"

Private Sub ComboBox1_Change()
Select Case ComboBox1

Case Is = "[the names of individual constellations 1]"
'add run [the names of individual constellations 1]'s macro
Case Is = "[the names of individual constellations 2]"
'add run [the names of individual constellations 2]'s macro
Case is=.....
......
End Select

End Sub
 
Back
Top