Hello all,
my name is Stefan and im very very new with VBA,
i managed to make a new Worksheet by clicking on the cmdbutton and give it the same name as in textbox1
but now i want the data from textbox2 and textbox3 in the newly maked worksheet
can somebody please help me.
this is the code for making my new worksheet:
Private Sub cmdVogelOpslaan_Click()
'create new worksheet with name
Worksheets(1).Select
Dim strNewName As String
Dim ws As Worksheet
Dim boolFound As Boolean
'pull sheet name from Textbox1
strNewName = txtNaam.Value
For Each ws In Worksheets
If ws.Name Like strNewName Then boolFound = True: Exit For
Next
'If sheet already exists
If boolFound = True Then
MsgBox ("Sheet already exists, please enter a new name or click on Cancel to close")
'If sheet does not already exist, add sheet
Else
Sheets.Add.Name = strNewName
'move worksheet to second sheet on list
Worksheets(1).Move Before:=Sheets(3)
'close userform if sheet added
Unload Me
End If
'userform still active if sheet not added
End Sub
Bookmarks