ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA Worksheet change name (https://www.excelbanter.com/excel-discussion-misc-queries/254422-vba-worksheet-change-name.html)

James C[_2_]

VBA Worksheet change name
 
I wish to change the name of a worksheet (Which name can be varied) to
apredetermined name say Sheet1.

I particular wish this be done within a VBA statement. I have one macro
that affects several workbooks and consequently the worksheets will have
different names and I wish to use a one predetermined name to cover this
variation.

Thanks
--
James

Chip Pearson

VBA Worksheet change name
 
You can rename the worksheet with code like

Worksheets("OldName").Name = "NewName"

If you want to get the new name from a cell value, use something like

Worksheets("OldName").Name = Range("A1").Text

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]



On Tue, 26 Jan 2010 07:57:01 -0800, James C
wrote:

I wish to change the name of a worksheet (Which name can be varied) to
apredetermined name say Sheet1.

I particular wish this be done within a VBA statement. I have one macro
that affects several workbooks and consequently the worksheets will have
different names and I wish to use a one predetermined name to cover this
variation.

Thanks


Gord Dibben

VBA Worksheet change name
 
How about using ActiveSheet in your code?

Or refer to the sheet codename

Worksheets(1) ignores the actual sheet name displayed on the sheet tab.


Gord Dibben MS Excel MVP

On Tue, 26 Jan 2010 07:57:01 -0800, James C
wrote:

I wish to change the name of a worksheet (Which name can be varied) to
apredetermined name say Sheet1.

I particular wish this be done within a VBA statement. I have one macro
that affects several workbooks and consequently the worksheets will have
different names and I wish to use a one predetermined name to cover this
variation.

Thanks




All times are GMT +1. The time now is 06:55 AM.

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