Previous in Forum: Protel DXP Gerber Files   Next in Forum: Choropleth Map Program
Close
Close
Close
8 comments
Rate Comments: Nested
Anonymous Poster

Excel Macro for Renaming Tabs

06/30/2009 12:03 PM

Hi all,

I have an excel workbook which has 30 sheets - one title sheet at the beginning and one admin sheet at the end. In between I have 28 sheets that are named by dates (mm.dd.yy).

What im looking for is a macro code that can rename those 28 sheets with the corresponding date that a vlookup formula puts into cell L1 of each individual sheet. For example, currently one of the sheets is titled by the date: 06.30.09. When next period opens up, I want to be able to run a macro that, when executed, will change that name to the date in L1 of that sheet. And, consequenlty, have the other 27 sheet name changed to the value in L1 of their corresponding sheets.

I'm hoping this is possible, as this is the final step in what I am trying to do.

Thanks for all your help!

Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru
Hobbies - Musician - Engineering Fields - Chemical Engineering - New Member Engineering Fields - Control Engineering - New Member Engineering Fields - Instrumentation Engineering - New Member

Join Date: Jan 2007
Location: Moses Lake, WA, USA, Thulcandra - The Silent Planet (C.S. Lewis)
Posts: 4216
Good Answers: 194
#1

Re: Rename Excel Sheet Tabs

06/30/2009 12:40 PM

Hi Guest,

Through macros? I don't know offhand - I'd have to play around a bit first. I'm sure it's possible through VBA*. Have you used VBA before?

Mike

*=Visual Basic for Applications

__________________
"Reason is not automatic. Those who deny it cannot be conquered by it. Do not count on them. Leave them alone." - Ayn Rand
Reply
Anonymous Poster
#2
In reply to #1

Re: Rename Excel Sheet Tabs

06/30/2009 12:46 PM

I'm pretty savvy with excel, but VBA is a little knew to me.

hopefully you can help!

Reply
Anonymous Poster
#3
In reply to #2

Re: Rename Excel Sheet Tabs

06/30/2009 12:48 PM

new*

Reply
Guru
Hobbies - Musician - Engineering Fields - Chemical Engineering - New Member Engineering Fields - Control Engineering - New Member Engineering Fields - Instrumentation Engineering - New Member

Join Date: Jan 2007
Location: Moses Lake, WA, USA, Thulcandra - The Silent Planet (C.S. Lewis)
Posts: 4216
Good Answers: 194
#4
In reply to #2

Re: Rename Excel Sheet Tabs

06/30/2009 4:40 PM

If I get a chance, I'll play around after work.

__________________
"Reason is not automatic. Those who deny it cannot be conquered by it. Do not count on them. Leave them alone." - Ayn Rand
Reply
Guru
Popular Science - Biology - life lover Hobbies - Musician - music lover Safety - Hazmat - better safe than sorry United Arab Emirates - Member - desert trek Technical Fields - Procurement - procurement

Join Date: Sep 2008
Location: Dubai, UAE
Posts: 744
Good Answers: 58
#5

Re: Excel Macro for Renaming Tabs

07/01/2009 8:51 AM

hi,

renaming tabs in MS Excel has already been addressed in these forums. it's here. it's not exactly what you're looking for, but it might give you an idea.

else, try this link. <-- this answer came from Chrisg288.

__________________
Now the darkness only stays the night-time, in the morning it will fade away. -- George Harrison (All Things Must Pass)
Reply
Participant

Join Date: Jun 2009
Location: São Paulo -
Posts: 4
#6

Re: Excel Macro for Renaming Tabs

07/02/2009 9:21 PM

Based on the 'langyaw' tip for this problem and considering the solution proposal by 'chrisg288' in the thread: "Renaming Worksheet Tabs in an Excel Workbook", You can do this:

- Open Excel and initiate a new macro record

- Give to macro the name "Rename Sheets"

- Stop Recorder without any command

Select Tools> Macros Or Developer>Macros and select the "Rename Sheets" macro.

Choose EDIT

Copy and paste the following code into macro (between Sub Rename Sheets and End Sub):

Sub RenameSheet()

'

' RenameSheet Macro

'

Dim content As String

Dim pointer As Integer

Dim Dsheets As Object

pointer = 0

For Each Dsheets In ActiveWorkbook.Sheets

SheetName = Dsheets.Name

If pointer > 0 Then

Sheets(SheetName).Select

content = Range("L1").Value

If content = vbNullString Then

content = "Nodate" & pointer

pointer = pointer + 1

End If

Dsheets.Name = content

Else

pointer = pointer + 1

End If

Next Dsheets

'Restore titles of last sheets

Sheets(content).Select

Sheets(content).Name = "End sheet"

End sub

Notes:

The code above was developed in Excel 2007.

Replace "End sheet" in the last line above with the name of the last sheet you really use.

The names for all sheets, excepted first and last one, is obtained from column L, row 1 in each sheet. If you change the address for names you must change line 13 where you see "L1" with new address.

Fco

Reply
Anonymous Poster
#8
In reply to #6

Re: Excel Macro for Renaming Tabs

04/09/2010 11:54 PM

Thanks a lot.

Amal

09804220099

Reply
Power-User
Engineering Fields - Electrical Engineering - New Member

Join Date: Aug 2007
Location: Toronto
Posts: 239
Good Answers: 9
#7

Re: Excel Macro for Renaming Tabs

07/03/2009 10:03 AM
Reply
Reply to Forum Thread 8 comments
Copy to Clipboard

Users who posted comments:

Anonymous Poster (3); FcoPSanches (1); Graebeard (1); langyaw (1); Mikerho (2)

Previous in Forum: Protel DXP Gerber Files   Next in Forum: Choropleth Map Program

Advertisement