VBA Code:
Private Sub AddUserButton_Click()
Dim iRow As Long
Dim ws As Worksheet
Dim Tbl As ListObject
'Find first empty row in Users List
iRow = Range("S" & Rows.Count).End(xlUp).Row + 1
'copy the data to the database, use protect and unprotect lines with your password if worksheet is protected
With Worksheets("Summary")
.Unprotect Password:=""
.Cells(iRow, 19).Value = Me.txtFirstName.Value
.Cells(iRow, 20).Value = Me.txtLastName.Value
'.Protect Password:=""
End With
'Clear names from the box
Me.txtFirstName.Value = ""
Me.txtLastName.Value = ""
'Focus on First name for another entry
Me.txtFirstName.SetFocus
'Make New Sheet for new user
Worksheets("Template").Copy After:=Worksheets(3)
ActiveSheet.Name = "Me.txtFirstName.Value" & " " & "Me.txtLastName.Value"
'Rename all table the name of sheet
For Each ws In Worksheets
For Each Tbl In ws.ListObjects
Tbl.Name = ws.Name
Exit For
Next Tbl
Next ws
End Sub
Private Sub CloseFormButton_Click()
Unload Me
End Sub
I am creating this sheet to send to other teams in the company for them to use. I want to automate the sheet to add new user to a running list of users on the team, then copy a template of a trip tracking sheet and rename that sheet as the new users name. Currently I have the running list and copying of the sheet running fine but the new sheets name based on new user is not working. I have tried putting txtFirstName in and out of quotations but nothing seems to work and the new sheet just shows up as a blank name. I would pull from a cell on the summary sheet that combines the first and last name but as new users are added they are the next available row so the cell needed to be pulled from would be changing each time. Any suggestions