How to rename a newly copied sheet using a userform?

crburke92

Board Regular
Joined
Feb 5, 2019
Messages
71
Looking to have a masterworkbook that when I go to a job, i can add sheets and rename them as I go since all sites name gear different. I have a set of template sheets hidden within the wookbook that I draw from, but I was hoping to have a userform with a simple text box pop up, type in the new sheet name I want, and hit "Okay" or something along those lines.

Code:
Sub New_Switch_Sheet()

Sheets("SWCH_TEMP").Visible = True
    Sheets("SWCH_TEMP").Copy After:=Sheets("SWCH_TEMP")
        Sheets("SWCH_TEMP").Visible = Flase
        
UserForm1.Show
End Sub

Just unsure how/if I'm able to make activesheet.name = "textbox value from userform"
Thanks in advance!
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about this?

Code:
Sub New_Switch_Sheet()
Dim wsName As String: wsName = Application.InputBox("Enter New SheetName")
Dim IDX As Integer: IDX = Sheets("SWCH_TEMP").Index

Sheets("SWCH_TEMP").Visible = True
Sheets("SWCH_TEMP").Copy After:=Sheets(IDX)
Sheets("SWCH_TEMP").Visible = False
Sheets(IDX + 1).Name = wsName
        
UserForm1.Show
End Sub
 
Upvote 0
Thats the one! I've never seen the Application.InputBox Before. Thats awesome, I like it. Thanks!
 
Upvote 0
───────────────────░█▓▓▓█░▇▆▅▄▃▂
──────────────────░█▓▓▓▓▓█░▇▆▅▄▃▂
─────────────────░█▓▓▓▓▓█░▇▆▅▄▃▂
──────────░░░───░█▓▓▓▓▓▓█░▇▆▅▄▃▂ ...
─────────░███░──░█▓▓▓▓▓█░▇▆▅▄▃▂
───────░██░░░██░█▓▓▓▓▓█░▇▆▅▄▃▂
──────░█░░█░░░░██▓▓▓▓▓█░▇▆▅▄▃▂
────░██░░█░░░░░░█▓▓▓▓█░▇▆▅▄▃▂
───░█░░░█░░░░░░░██▓▓▓█░▇▆▅▄▃▂
──░█░░░░█░░░░░░░░█▓▓▓█░▇▆▅▄▃▂
──░█░░░░░█░░░░░░░░█▓▓▓█░▇▆▅▄▃▂
──░█░░█░░░█░░░░░░░░█▓▓█░▇▆▅▄▃▂
─░█░░░█░░░░██░░░░░░█▓▓█░▇▆▅▄▃▂
─░█░░░░█░░░░░██░░░█▓▓▓█░▇▆▅▄▃▂
─░█░█░░░█░░░░░░███▓▓▓▓█░▇▆▅▄▃▂
░█░░░█░░░██░░░░░█▓▓▓▓▓█░▇▆▅▄▃▂
░█░░░░█░░░░█████▓▓▓▓▓█░▇▆▅▄▃▂
░█░░░░░█░░░░░░░█▓▓▓▓▓█░▇▆▅▄▃▂
░█░█░░░░██░░░░█▓▓▓▓▓█░▇▆▅▄▃▂
─░█░█░░░░░████▓▓▓▓██░▇▆▅▄▃▂
─░█░░█░░░░░░░█▓▓██▓█░▇▆▅▄▃▂
──░█░░██░░░██▓▓█▓▓▓█░▇▆▅▄▃▂
───░██░░███▓▓██▓█▓▓█░▇▆▅▄▃▂
────░██▓▓▓███▓▓▓█▓▓▓█░▇▆▅▄▃▂
──────░█▓▓▓▓▓▓▓▓█▓▓▓█░▇▆▅▄▃▂
──────░█▓▓▓▓▓▓▓▓▓▓▓▓▓█░▇▆▅▄▃▂
 
Upvote 0
How about this?

Code:
Sub New_Switch_Sheet()
Dim wsName As String: wsName = Application.InputBox("Enter New SheetName")
Dim IDX As Integer: IDX = Sheets("SWCH_TEMP").Index

Sheets("SWCH_TEMP").Visible = True
Sheets("SWCH_TEMP").Copy After:=Sheets(IDX)
Sheets("SWCH_TEMP").Visible = False
Sheets(IDX + 1).Name = wsName
        
UserForm1.Show
End Sub

I would try this:

Code:
Sheets("SWCH_TEMP").Visible = True
Sheets("SWCH_TEMP").Copy After:=Sheets(IDX)
ActiveSheet.Name = wsName
Sheets("SWCH_TEMP").Visible = False
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,954
Members
448,535
Latest member
alrossman

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