Hi,
I'm trying to set up a command button that executes an action based on the combo box selection. The command button runs a plotting macro that is always the same, however, the combo box is used to select the worksheet which provides the data the plotting macro will apply to. All the data worksheets are laid out the same.
The macro is set up so the data plotted is from the ActiveSheet, which is referenced to by the string strSheetName. I was trying to use the combobox selection to set strSheetName equal to the worksheet chosen, and then activate this worksheet before running the plotting macro.
My problem is that I keep getting a compilation error: object required. The error shows up first in the line Set strSheetName As String. I tried initializing strSheetName as Public or Global, but Public had the same problem and Global wouldn't work for the string...this combo box code is in sheet20, whereas the macro is in a module (i hope that is okay).
Here's my code so far:
Formula:
Private Sub CBox1_Click()
Dim strSheetName As String
If CBox1 = FB1 Then
Set strSheetName = Worksheets("FB1")
End If
If CBox1 = FB2 Then
Set strSheetName = Worksheets("FB2")
End If
If CBox1 = FB3 Then
Set strSheetName = Worksheets("FB3")
End If
If CBox1 = FB4 Then
Set strSheetName = Worksheets("FB4")
End IfWorksheets(strSheetName).Activate
Application.Run ("GraphFB6")
strSheetName = Empty
End Sub
Any help is greatly appreciated!
Dan
Bookmarks