Hi,
I am trying to set the worksheet name in my code to that of a selection from a combobox. I cant seem to get the code right for this part, the rest works fine can anyone help?
Regards
I am trying to set the worksheet name in my code to that of a selection from a combobox. I cant seem to get the code right for this part, the rest works fine can anyone help?
Regards
Rich (BB code):
Private Sub CommandButton1_Click()
Dim lr As Long
Dim x As Long
Dim list As String
Dim ws1 As Worksheet
Dim sh As String
ws1 = Me.cboSheet - Problem with this line
With ws1
lr = .Range("B" & Rows.Count).End(xlUp).Row
End With
For x = 10 To lr
With ws1
list = .Range("B" & x) & " " & .Range("C" & x)
Me.cboList.AddItem list
End With
Next x
End Sub
Private Sub UserForm_Initialize()
Dim sh As String
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
sh = ws.Name
Me.cboSheet.AddItem sh
Next ws
End Sub