Login | Register

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

Comments Format:






Close

Subscribe to Discussion:

CR4 allows you to "subscribe" to a discussion
so that you can be notified of new comments to
the discussion via email.

Close

Rating Vote:







7 comments
Guest

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!

Send to a friend Digg this Add to del.icio.us
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: Akron, OH, USA, The Silent Planet
Posts: 947
Good Answers: 29
#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

__________________
"Try not. Do or do not, there is no 'try'." Yoda
Guest
#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!

Guest
#3
In reply to #2

Re: Rename Excel Sheet Tabs

06/30/2009 12:48 PM

new*

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: Akron, OH, USA, The Silent Planet
Posts: 947
Good Answers: 29
#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.

__________________
"Try not. Do or do not, there is no 'try'." Yoda
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: 624
Good Answers: 50
#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.

__________________
Sign at Shoe Repair Shop: I WILL HEEL YOU. I WILL SAVE YOUR SOLE. I WILL EVEN DYE FOR YOU.
Participant

Join Date: Jun 2009
Posts: 2
#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

Power-User
Engineering Fields - Electrical Engineering - New Member

Join Date: Aug 2007
Location: Toronto - Picture from Lake Superior
Posts: 188
Good Answers: 6
#7

Re: Excel Macro for Renaming Tabs

07/03/2009 10:03 AM
7 comments
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Copy to Clipboard

Users who posted comments:

FcoPSanches (1), Graebeard (1), Guest (2), langyaw (1), Mikerho (2)

Previous in Forum: Protel DXP Gerber Files   Next in Forum: Choropleth Map Program
You might be interested in: Varactor Diodes, PIN Diodes, General Purpose Diodes