ankita.sethi
Board Regular
- Joined
- Apr 27, 2011
- Messages
- 58
Hi,
I have written 3 VBA macros, namely:
chart_inprogress_Category
chart_inprogress_StrategicAlignment
chart_inprogress_investmentName
These macros change 1 common chart - based on certain criteras.
I want to create 1 combobox where the user can choose which one is wanted.
Here is the code I have written in the "Worksheet" code window
Private Sub Worksheet_Activate()
ComboBox1.Clear
ComboBox1.AddItem "Category"
ComboBox1.AddItem "StrategicAlignment"
ComboBox1.AddItem "Investment Name"
ComboBox1.Text = ComboBox1.List(0)
End Sub
Private Sub ComboBox1_Change()
Select Case ComboBox1.Text
Case "Category"
chart_inprogress_Category
Case "StrategicAlignment"
chart_inprogress_StrategicAlignment
Case "Investment Name"
chart_inprogress_investmentName
Case Else
End Select
End Sub
Howeve, this is throwing an error. In the combobox, no matter what value I choose, it comes back to the first one "Category".
Moreover, if I run the macro individually, they run fine. But running through combobox is giving an error (even running for 'Category').
Error: "Object Variable or with block variable not set"
PLEASE HELP!!
I have written 3 VBA macros, namely:
chart_inprogress_Category
chart_inprogress_StrategicAlignment
chart_inprogress_investmentName
These macros change 1 common chart - based on certain criteras.
I want to create 1 combobox where the user can choose which one is wanted.
Here is the code I have written in the "Worksheet" code window
Private Sub Worksheet_Activate()
ComboBox1.Clear
ComboBox1.AddItem "Category"
ComboBox1.AddItem "StrategicAlignment"
ComboBox1.AddItem "Investment Name"
ComboBox1.Text = ComboBox1.List(0)
End Sub
Private Sub ComboBox1_Change()
Select Case ComboBox1.Text
Case "Category"
chart_inprogress_Category
Case "StrategicAlignment"
chart_inprogress_StrategicAlignment
Case "Investment Name"
chart_inprogress_investmentName
Case Else
End Select
End Sub
Howeve, this is throwing an error. In the combobox, no matter what value I choose, it comes back to the first one "Category".
Moreover, if I run the macro individually, they run fine. But running through combobox is giving an error (even running for 'Category').
Error: "Object Variable or with block variable not set"
PLEASE HELP!!