Quintin8709
New Member
- Joined
- Apr 14, 2019
- Messages
- 1
MREXCEL
Can you please help on this. I've got a combobox in a userform. I'm trying to assign a variable called shtRB to different worksheets depending on the cb selected value.
Private Sub CommandButton1_Click()
Dim shtrb As Worksheet
Dim namecell As String
Dim datecell As Date
If ufRB.cbtype.Value = "weekly" Then
Set shtrb = Worksheets("1")
Else
Set shtrb = Worksheets("2")
End If
'cells names gives error object required
Set namecell = shtrb.Range("D11")
Set datecell = shtrb.Range("j11")
namecell.Value = ufRB.tbname.Value
datecell.Value = ufRB.tbdate.Value
End Sub
Can you please help on this. I've got a combobox in a userform. I'm trying to assign a variable called shtRB to different worksheets depending on the cb selected value.
Private Sub CommandButton1_Click()
Dim shtrb As Worksheet
Dim namecell As String
Dim datecell As Date
If ufRB.cbtype.Value = "weekly" Then
Set shtrb = Worksheets("1")
Else
Set shtrb = Worksheets("2")
End If
'cells names gives error object required
Set namecell = shtrb.Range("D11")
Set datecell = shtrb.Range("j11")
namecell.Value = ufRB.tbname.Value
datecell.Value = ufRB.tbdate.Value
End Sub