ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   rename worksheet based on contents of a cell in different workshee (https://www.excelbanter.com/excel-discussion-misc-queries/143198-rename-worksheet-based-contents-cell-different-workshee.html)

OfficeNDN

rename worksheet based on contents of a cell in different workshee
 
I have three worksheets within a workbook. The three worksheets are named

"Account Info"
"sep 27,2006"
"lists"

I would like to automatically rename the second worksheet "sep 27, 2006"
based on the contents of cell B6 in the "Account Info" worksheet. The
contents of B6 will be a date in the above format.

The workbook is a template.

How do I do that? I figure I need to right-click the worksheet tab and
enter vba code into the Visual Basic Editor but what is the code?

Can I copy and paste the code or is that not possible?

Mike

rename worksheet based on contents of a cell in different workshee
 
try this
Sub RenameSheet()
Worksheets(2).Name = _
Format(Worksheets("Account Info").Range("B6"), _
"[$-409]mmm dd,yyyy;@")
End Sub

"OfficeNDN" wrote:

I have three worksheets within a workbook. The three worksheets are named

"Account Info"
"sep 27,2006"
"lists"

I would like to automatically rename the second worksheet "sep 27, 2006"
based on the contents of cell B6 in the "Account Info" worksheet. The
contents of B6 will be a date in the above format.

The workbook is a template.

How do I do that? I figure I need to right-click the worksheet tab and
enter vba code into the Visual Basic Editor but what is the code?

Can I copy and paste the code or is that not possible?



All times are GMT +1. The time now is 10:25 AM.

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