ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Renaming worksheet tabs (https://www.excelbanter.com/excel-programming/279516-renaming-worksheet-tabs.html)

Dave[_31_]

Renaming worksheet tabs
 
Hi
I dont know if anyone can help me, but I am having problems
renaming the worksheet tabs on a spreadsheet.

I have set up a procedure that when run, opens a dialog box
and asks the user to input a name into a text box.
This name is then copied and pasted to a cell on a worksheet.

I then take a copy of an existing worksheet, and the
intention is to get Excel to automatically rename the new
copy with the name entered in the text box and pasted to
the sheet (if you see what I mean).

I am using the following code to try this last part:

Sheets("WORKSHEET").Select
Range("A1").Select ----- cell holding the name
Selection.Copy
Sheets("NEWWORKSHEET").Select ----new copy of the sheet
Sheets("NEWWORKSHEET").Name = ???????

It is the ????? I cannot seem to do. If I record a macro
of me copying the name and pasting it, the code comes out
with the actual text, not a generic "whatever is on the
clipboard".

Is there a simple way of adding this to the code, so that
whatever is entered in cell A1 can be used to rename the
worksheet??

Thanks in advance for your help

Dave

[email protected]

Renaming worksheet tabs
 
Sheets("NEWWORKSHEET").Name = Sheets("WORKSHEET").Range("A1").Value

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------
Hi
I dont know if anyone can help me, but I am having problems
renaming the worksheet tabs on a spreadsheet.

I have set up a procedure that when run, opens a dialog box
and asks the user to input a name into a text box.
This name is then copied and pasted to a cell on a worksheet.

I then take a copy of an existing worksheet, and the
intention is to get Excel to automatically rename the new
copy with the name entered in the text box and pasted to
the sheet (if you see what I mean).

I am using the following code to try this last part:

Sheets("WORKSHEET").Select
Range("A1").Select ----- cell holding the name
Selection.Copy
Sheets("NEWWORKSHEET").Select ----new copy of the sheet
Sheets("NEWWORKSHEET").Name = ???????

It is the ????? I cannot seem to do. If I record a macro
of me copying the name and pasting it, the code comes out
with the actual text, not a generic "whatever is on the
clipboard".

Is there a simple way of adding this to the code, so that
whatever is entered in cell A1 can be used to rename the
worksheet??

Thanks in advance for your help

Dave



Marty Lindower

Renaming worksheet tabs
 
Dave-

Here's the code I'm using to do something similar, and
it does work:

Sheets("Worksheet").Activate
NewSheetName = Range("A1")
Worksheets("Worksheet").Copy _
After:=Sheets(Sheets.Count) 'this puts the new
sheet after all current ones
ActiveSheet.Name = NewSheetName

Hope that helps,
Marty

Sheets("WORKSHEET").Select
Range("A1").Select ----- cell holding the name
Selection.Copy
Sheets("NEWWORKSHEET").Select ----new copy of the sheet
Sheets("NEWWORKSHEET").Name = ???????


Marty Lindower

Renaming worksheet tabs
 
oops- that Range("a1") statement may need a .value
appended to it....

Mark heyhoe

Renaming worksheet tabs
 
Hi,
Assuming they are in the same workbook, you could just try:

Sheets("NEWWORKSHEET").Name = Sheets("WORKSHEET").Range
("A1").value

Regards,
Mark

-----Original Message-----
Hi
I dont know if anyone can help me, but I am having

problems
renaming the worksheet tabs on a spreadsheet.

I have set up a procedure that when run, opens a dialog

box
and asks the user to input a name into a text box.
This name is then copied and pasted to a cell on a

worksheet.

I then take a copy of an existing worksheet, and the
intention is to get Excel to automatically rename the new
copy with the name entered in the text box and pasted to
the sheet (if you see what I mean).

I am using the following code to try this last part:

Sheets("WORKSHEET").Select
Range("A1").Select ----- cell holding the name
Selection.Copy
Sheets("NEWWORKSHEET").Select ----new copy of the sheet
Sheets("NEWWORKSHEET").Name = ???????

It is the ????? I cannot seem to do. If I record a macro
of me copying the name and pasting it, the code comes out
with the actual text, not a generic "whatever is on the
clipboard".

Is there a simple way of adding this to the code, so that
whatever is entered in cell A1 can be used to rename the
worksheet??

Thanks in advance for your help

Dave
.



All times are GMT +1. The time now is 12:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com