Want to create new a new sheet based on user form input but cant get the new sheet to name correctly and just shows up as blank name.

alleneure

New Member
Joined
Feb 22, 2023
Messages
17
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I solved my own problem. I was clearing names before new sheet creation.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top