life_in_picture_format
New Member
- Joined
- Dec 8, 2021
- Messages
- 26
- Office Version
- 365
- Platform
- Windows
- Mobile
- Web
Hello I need assistance. I cannot for the life of me figure out how to get this to work
fig 1: shows my empty table and this same Worksheet ("Worksheet 1" we will call it) I have ListBox1 populated with each month and CommandButton1 which is to be clicked after selecting a month from ListBox1:
Each month has a separate macro tied to it for example, If the user selects "January" and clicks "Launch Report", its associated macro "RunJan" will trigger and populate the table with data from my January sheet. I have the RunJan macro figured out.
I can't figure out how to properly write a the trigger for each macro depending on the ListBox1 selection.
Currently I have the following code nested in Worksheet1 with just RunJan macro.
Private Sub Workbook_Open()
fig 1: shows my empty table and this same Worksheet ("Worksheet 1" we will call it) I have ListBox1 populated with each month and CommandButton1 which is to be clicked after selecting a month from ListBox1:
Each month has a separate macro tied to it for example, If the user selects "January" and clicks "Launch Report", its associated macro "RunJan" will trigger and populate the table with data from my January sheet. I have the RunJan macro figured out.
I can't figure out how to properly write a the trigger for each macro depending on the ListBox1 selection.
Currently I have the following code nested in Worksheet1 with just RunJan macro.
Private Sub Workbook_Open()
VBA Code:
With Worksheets("Worksheet1").ListBox1
ListBox1.AddItem " "
ListBox1.AddItem "January"
ListBox1.AddItem "February"
ListBox1.AddItem "March"
ListBox1.AddItem "April"
ListBox1.AddItem "May"
ListBox1.AddItem "June"
ListBox1.AddItem "July"
ListBox1.AddItem "August"
ListBox1.AddItem "September"
ListBox1.AddItem "October"
ListBox1.AddItem "November"
ListBox1.AddItem "December"
End With
End Sub
Private Sub LaunchReport_Click()
If ListBox1.Value = "January" Then
Call RunJan
End If
End Sub