use textbox content to copy and rename worksheet

stewie09

New Member
Joined
Sep 23, 2006
Messages
3
Can anyone please help me with this Excel task? I am trying to create a macro which I will allow me to enter a name in a textbox on a userform. Then when I click on the Create button, the macros makes a copy of a worksheet (the worksheet is currently named Cal2007.). After making the copy. The copied worksheet should be renamed using the name that was entered in the text box.

Thanks
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
Hello stewie09, welcome to the board.
Assuming your textbox is still named 'TextBox1' you can use something like this
for the code in your userform's Create button.
Code:
Sheets("Cal2007").Copy Before:=Sheets(1)
ActiveSheet.Name = TextBox1.Value
 

stewie09

New Member
Joined
Sep 23, 2006
Messages
3
HalfAce, thank you very much for providing the code. I really appreciate your help.
 

Forum statistics

Threads
1,136,427
Messages
5,675,777
Members
419,585
Latest member
popsin

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
Top