I want to add a new worksheet and name it from a user form's text box value. Please help. Thank you.
Dim CampDate As String
CampDate = RegisterCamp.CampDate
If CampDate <> "" Then
MsgBox (CampDate)
Sheets.Add.Name = CampDate
End If
I want to add a new worksheet and name it from a user form's text box value. Please help. Thank you.
Dim CampDate As String
CampDate = RegisterCamp.CampDate
If CampDate <> "" Then
MsgBox (CampDate)
Sheets.Add.Name = CampDate
End If
Add the .Text
:
Private Sub CommandButton1_Click()
Dim CampDate As String
CampDate = RegisterCamp.CampDate.Text
If CampDate <> "" Then
MsgBox (CampDate)
Sheets.Add.Name = CampDate
End If
End Sub
This Code works fine:
Option Explicit
Private Sub CommandButton1_Click()
Dim strCampDate As String
Dim ws As Worksheet
strCampDate = UserForm1.TextBox1.Value
If strCampDate <> "" Then
Set ws = ThisWorkbook.Sheets.Add
ws.Name = strCampDate
End If
End Sub