ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dynamic naming of worksheets (https://www.excelbanter.com/excel-programming/318694-dynamic-naming-worksheets.html)

Zyvind

Dynamic naming of worksheets
 
Hi,
I am developing a macro in which I add new sheets to a database every time I
export data to it. In order to recognize these sheets, I would like to be
able to make the name of the sheet equal to the contents of a cell in the
exported sheet. Currently, the code reads

Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Name"

Is there anyway that I can make the "Name" - part into a dynamic
cell-reference?

Thanks
Zyvind

Ben McBen[_2_]

Dynamic naming of worksheets
 
Just use:


Sheets("Sheet1").Name = Sheets("Sheet1").Range("A1")

or

Sheets("Sheet1").Name = yourStringVariableHere

or

Sheets("Sheet1").Name = Sheets("Sheet1").Range
(yourrangenamevariable)

or

Sheets("Sheet1").Name = Sheets("Sheet1").cells(1,1)


etc

ttfn benm




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

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