ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Rename wrksht tab from cell info w/Macro (https://www.excelbanter.com/excel-programming/285780-rename-wrksht-tab-cell-info-w-macro.html)

bobgerman

Rename wrksht tab from cell info w/Macro
 
Can anyone help me with Macro code that will rename a worksheet ta
referencing info found in a cell?

When recording the macro, I pointed to the cell, right clicked an
copied the cell. Then double clicked on the tab to be renamed an
Ctrl-V to paste the copied information. However, the recorded macr
looks like this:

Sub RenameTab()
'
' RenameTab Macro
' Macro recorded 12/18/2003 by Bob G.
'
' Keyboard Shortcut: Ctrl+Shift+S
'
Range("E2").Select
Selection.Copy
Sheets("TAB").Select
Sheets("TAB").Name = "123456"
End Sub

In the 'Sheets("TAB").Name = "123456" ' line I would like to referenc
the absolute cell on that particular worksheet to get the info for th
new tab (worksheet) name. The "123456" is the info that was in the cel
when I copied it.

Thanks

--
Message posted from http://www.ExcelForum.com


Don Guillett[_4_]

Rename wrksht tab from cell info w/Macro
 
Instead of this
Range("E2").Select
Selection.Copy
Sheets("TAB").Select
Sheets("TAB").Name = "123456"
End Sub

use
Sheets("TAB").Name = [e2]

--
Don Guillett
SalesAid Software

"bobgerman" wrote in message
...
Can anyone help me with Macro code that will rename a worksheet tab
referencing info found in a cell?

When recording the macro, I pointed to the cell, right clicked and
copied the cell. Then double clicked on the tab to be renamed and
Ctrl-V to paste the copied information. However, the recorded macro
looks like this:

Sub RenameTab()
'
' RenameTab Macro
' Macro recorded 12/18/2003 by Bob G.
'
' Keyboard Shortcut: Ctrl+Shift+S
'
Range("E2").Select
Selection.Copy
Sheets("TAB").Select
Sheets("TAB").Name = "123456"
End Sub

In the 'Sheets("TAB").Name = "123456" ' line I would like to reference
the absolute cell on that particular worksheet to get the info for the
new tab (worksheet) name. The "123456" is the info that was in the cell
when I copied it.

Thanks.


---
Message posted from
http://www.ExcelForum.com/




Nigel[_8_]

Rename wrksht tab from cell info w/Macro
 
Try this to set the tab name on the first worksheet to the contents of the
cell E2. Change the references to suit your needs. By referencing the sheet
and cells by index values you can programmatically set the values if you
need to.
Note: You cannot have two sheets with the same name so you might want to
check the value of the sheetname before you try to set it to one that
already exists.

Sub RenameTab()
With Worksheets(1)
' set the cell content to name the sheet (tab) by row,col
.Name = .Cells(2, 5)
End With
EndSub

Cheers
Nigel

"bobgerman" wrote in message
...
Can anyone help me with Macro code that will rename a worksheet tab
referencing info found in a cell?

When recording the macro, I pointed to the cell, right clicked and
copied the cell. Then double clicked on the tab to be renamed and
Ctrl-V to paste the copied information. However, the recorded macro
looks like this:

Sub RenameTab()
'
' RenameTab Macro
' Macro recorded 12/18/2003 by Bob G.
'
' Keyboard Shortcut: Ctrl+Shift+S
'
Range("E2").Select
Selection.Copy
Sheets("TAB").Select
Sheets("TAB").Name = "123456"
End Sub

In the 'Sheets("TAB").Name = "123456" ' line I would like to reference
the absolute cell on that particular worksheet to get the info for the
new tab (worksheet) name. The "123456" is the info that was in the cell
when I copied it.

Thanks.


---
Message posted from http://www.ExcelForum.com/





----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

bobgerman[_2_]

Rename wrksht tab from cell info w/Macro
 
Don,

Thank you VERY much. You have made my day.

Bob G

--
Message posted from http://www.ExcelForum.com


Don Guillett[_4_]

Rename wrksht tab from cell info w/Macro
 
glad to help

--
Don Guillett
SalesAid Software

"bobgerman" wrote in message
...
Don,

Thank you VERY much. You have made my day.

Bob G.


---
Message posted from
http://www.ExcelForum.com/





All times are GMT +1. The time now is 04:06 PM.

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