ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   using VBA to rename active sheet (https://www.excelbanter.com/excel-programming/313684-using-vba-rename-active-sheet.html)

Papa Jonah

using VBA to rename active sheet
 
I am writing some vba to run some stuff. Part of this includes naming,
copying, and returning to various sheets.
I want the write a code that will rename the first sheet "Data (altered)".
I can't seem to figure out how to do that. Any help would be much
appreciated.

TIA

Tom Ogilvy

using VBA to rename active sheet
 
Worksheets(1).Name = "Data (altered)"

--
Regards,
Tom Ogilvy

"Papa Jonah" wrote in message
...
I am writing some vba to run some stuff. Part of this includes naming,
copying, and returning to various sheets.
I want the write a code that will rename the first sheet "Data (altered)".
I can't seem to figure out how to do that. Any help would be much
appreciated.

TIA




kkknie[_235_]

using VBA to rename active sheet
 

If you are renaming the active sheet use:

ActiveSheet.Name = "Date (altered)"

If you are renaming the first sheet use:

Sheets(1).Name = "Date (altered)"

If you are renaming a sheet with a specific name use:

Sheets("Sheet1").Name = "Date (altered)"




--
kkkni
-----------------------------------------------------------------------
kkknie's Profile: http://www.excelforum.com/member.php...nfo&userid=754
View this thread: http://www.excelforum.com/showthread.php?threadid=26966


Papa Jonah

using VBA to rename active sheet
 
That worked! thanks

"Tom Ogilvy" wrote:

Worksheets(1).Name = "Data (altered)"

--
Regards,
Tom Ogilvy

"Papa Jonah" wrote in message
...
I am writing some vba to run some stuff. Part of this includes naming,
copying, and returning to various sheets.
I want the write a code that will rename the first sheet "Data (altered)".
I can't seem to figure out how to do that. Any help would be much
appreciated.

TIA





Keri

using VBA to rename active sheet
 
Hi, what you said before is really good,

Do you know how I can make it work so that I can make Sheet1 become renamed
"1", sheet 2 is renamed "2", sheet 3 become "3" and then I can add multiple
sheets in the same sequence?

If you can help it would be much appreciated.

Thanks.

"kkknie" wrote:


If you are renaming the active sheet use:

ActiveSheet.Name = "Date (altered)"

If you are renaming the first sheet use:

Sheets(1).Name = "Date (altered)"

If you are renaming a sheet with a specific name use:

Sheets("Sheet1").Name = "Date (altered)"


K


--
kkknie
------------------------------------------------------------------------
kkknie's Profile: http://www.excelforum.com/member.php...fo&userid=7543
View this thread: http://www.excelforum.com/showthread...hreadid=269668



kkknie[_246_]

using VBA to rename active sheet
 

Not sure exactly what your up to, but here's my thoughts:

Sheets("Sheet1").Name = 1
Sheets("Sheet2").Name = 2
Sheets("Sheet3").Name = 3

Or if you want to do them in a loop based on their orignal names,

Dim i As Integer

For i = 1 to 3
Sheets("Sheet" & i).Name = i
Next

If you want to just rename the sheets based on how they are currentl
ordered,

Dim i As Integer

For i = 1 To Worksheets.Count
Sheets(i).Name = i
Next

Hope this helps,



--
kkkni
-----------------------------------------------------------------------
kkknie's Profile: http://www.excelforum.com/member.php...nfo&userid=754
View this thread: http://www.excelforum.com/showthread.php?threadid=26966



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

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