ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Referencing a new worksheet (https://www.excelbanter.com/excel-programming/280454-referencing-new-worksheet.html)

Paul W Smith[_2_]

Referencing a new worksheet
 
How do I refer to a new worksheets created by copying an existing sheet.

I have the following code:

worksheets("Test").copy after:=worksheets(worksheets.count)

This creates a new worksheet called "Test (2)", I now want to be able to
rename that newly created worksheet.

I thought worksheets(worksheets.count) would always be the last create
worksheet, but this does not seem to be the case.

Can someone please tell me how to reference a newly created worksheet.

Paul Smith



Cesar Zapata[_2_]

Referencing a new worksheet
 
did you try active.worksheet ?



CEsar





"Paul W Smith" wrote in message
...
How do I refer to a new worksheets created by copying an existing sheet.

I have the following code:

worksheets("Test").copy after:=worksheets(worksheets.count)

This creates a new worksheet called "Test (2)", I now want to be able to
rename that newly created worksheet.

I thought worksheets(worksheets.count) would always be the last create
worksheet, but this does not seem to be the case.

Can someone please tell me how to reference a newly created worksheet.

Paul Smith





Cesar Zapata[_2_]

Referencing a new worksheet
 
well. in this case that will be the active sheet. then you can do
activesheet.name = "NewSheet"



"Paul W Smith" wrote in message
...
How do I refer to a new worksheets created by copying an existing sheet.

I have the following code:

worksheets("Test").copy after:=worksheets(worksheets.count)

This creates a new worksheet called "Test (2)", I now want to be able to
rename that newly created worksheet.

I thought worksheets(worksheets.count) would always be the last create
worksheet, but this does not seem to be the case.

Can someone please tell me how to reference a newly created worksheet.

Paul Smith






All times are GMT +1. The time now is 04:19 AM.

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