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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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
───────────────────░█▓▓▓█░▇▆▅▄▃▂
──────────────────░█▓▓▓▓▓█░▇▆▅▄▃▂
─────────────────░█▓▓▓▓▓█░▇▆▅▄▃▂
──────────░░░───░█▓▓▓▓▓▓█░▇▆▅▄▃▂ ...
─────────░███░──░█▓▓▓▓▓█░▇▆▅▄▃▂
───────░██░░░██░█▓▓▓▓▓█░▇▆▅▄▃▂
──────░█░░█░░░░██▓▓▓▓▓█░▇▆▅▄▃▂
────░██░░█░░░░░░█▓▓▓▓█░▇▆▅▄▃▂
───░█░░░█░░░░░░░██▓▓▓█░▇▆▅▄▃▂
──░█░░░░█░░░░░░░░█▓▓▓█░▇▆▅▄▃▂
──░█░░░░░█░░░░░░░░█▓▓▓█░▇▆▅▄▃▂
──░█░░█░░░█░░░░░░░░█▓▓█░▇▆▅▄▃▂
─░█░░░█░░░░██░░░░░░█▓▓█░▇▆▅▄▃▂
─░█░░░░█░░░░░██░░░█▓▓▓█░▇▆▅▄▃▂
─░█░█░░░█░░░░░░███▓▓▓▓█░▇▆▅▄▃▂
░█░░░█░░░██░░░░░█▓▓▓▓▓█░▇▆▅▄▃▂
░█░░░░█░░░░█████▓▓▓▓▓█░▇▆▅▄▃▂
░█░░░░░█░░░░░░░█▓▓▓▓▓█░▇▆▅▄▃▂
░█░█░░░░██░░░░█▓▓▓▓▓█░▇▆▅▄▃▂
─░█░█░░░░░████▓▓▓▓██░▇▆▅▄▃▂
─░█░░█░░░░░░░█▓▓██▓█░▇▆▅▄▃▂
──░█░░██░░░██▓▓█▓▓▓█░▇▆▅▄▃▂
───░██░░███▓▓██▓█▓▓█░▇▆▅▄▃▂
────░██▓▓▓███▓▓▓█▓▓▓█░▇▆▅▄▃▂
──────░█▓▓▓▓▓▓▓▓█▓▓▓█░▇▆▅▄▃▂
──────░█▓▓▓▓▓▓▓▓▓▓▓▓▓█░▇▆▅▄▃▂
 
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,224,609
Messages
6,179,877
Members
452,949
Latest member
Dupuhini

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