Excel List Box
Assume the listbox is on Worksheets(1) and the range
with the data is on Worksheets(2).Range("A2:A21"):
Private Sub fillLstBx()
Dim ws1, ws2 As Worksheet
ws1.ListBox1.RowSource = ws2.Range("A2:A21").Address
End Sub
The above code could go into either the worksheet which
has the listbox or delete the private from the title line
and put it in the VBA module.
The following code would go into the listbox click event.
Right click the control and click view code to open the code
window. myMacro would be the name of the macro you want to
call.
Private Sub ListBox1_Click()
myMacro
End Sub
" wrote:
I need help to create a Macro to fill a list box with names from
another sheet and then when the list box changes to activate another
macro that will display some charts.
So far I only have the following code:
Range("B5").Select
ActiveWorkbook.Names.Add Name:="EmployeeNames", RefersToR1C1:= _
"=Employees!R1C1:R230C1"
ActiveWorkbook.Names.Add Name:="EmployeeNames", RefersToR1C1:= _
"=Employees!R1C1:R230C1"
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _
xlBetween, Formula1:="=EmployeeNames"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
I got it from using th emacro recorder. Now I am stuck
Can someone please help me
Thank you
|