vba courses london - change a tab name
Microsoft Office Training verified by visa - mastercard securecode about microsoft training company london ukadd this page to your favourites/bookmarksAdd to favourites
view a printable version of this pagePrintable version
email this page to somebodyEmail this page
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft VBA Training and help » vba courses london - Change A Tab Name on Multiple Workbooks in Different Locations

vba courses london - Change A Tab Name on Multiple Workbooks in Different Locations

The UK's most regular instructor-led training courses.
Training information: vba courses london · Excel london

resolvedResolved · Low Priority · Version Standard

Change A Tab Name on Multiple Workbooks in Different Locations

Simon has attended:
Excel VBA course

by - delegate Simon [4 posts] (2007 Apr 19 Thu, 09:46) replyReply

Dear Sir / Madam,

I have 32 Spreadsheets. They are all named differently but all end in the word "Commentary". Each Speadsheet has 2 tabs only. One of these tabs on each spreadsheet is labelled "Period 1".

Each Month I have to go through each Spreadsheet and change the "Period 1" to "Period 2" and so forth...

I am trying to write a procedure which assigned to a Command Button, will automatically change the above on all 32 Spreadsheets.

I managed to find some code on the net which searches my folder and finds all Spreadsheets which contains the word "Commentary", but then I can't manage to write a procedure after this for it to change the relevant tab.

Am I heading in the right direction? Any help or advice on this would be greatfully received and very much appreciated.

Kind Regards,

Simon.

RE: Change A Tab Name on Multiple Workbooks in Different Locatio

by - trainer Carlos gold contributer[479 posts] (2007 Apr 19 Thu, 10:01) replyReply

Simon

To channge the Tab name on a sheet use the following code:

Open the relevant Workbook then


Sheets("Period 1").Select
ActiveSheet.Name = "Period 2"


This changes the name of the sheet to Period 2

Hope this helps

Regards

Carlos

RE: Change A Tab Name on Multiple Workbooks in Different Locatio

by - delegate Simon [4 posts] (2007 Apr 19 Thu, 10:53) replyReply

Hello Carlos,

Thank you very much for the swift reply in response to my question.

This works perfectly.

However could I possibly ask how I can combine this statement to change all of the tabs in my spreadsheets with one click. What I would like is a command button on a new spreadsheet which I click once and then this opens all the spreadsheets say one at a time and changes the tab then saves and closes it.

Apologies for requesting more information. Hope you can help?

Kind Regards,

Simon.

RE: Change A Tab Name on Multiple Workbooks in Different Locatio

by - trainer Carlos gold contributer[479 posts] (2007 Apr 19 Thu, 14:35) Edited on 2007 Apr 19 Thu, 14:36 replyReply

Simon

You need to create a Sub routine that contains a loop that opens all the Workbooks one at a time and changes the tab name eg

Create a variable eg Dim MyWorkbook as String

And load into it, the Workbook’s path name one at a time, from a list. Then create a loop similar to the one below: (I’ve used the DO loop but you can try others)

NB This is a guideline only. You will need to adapt it to your situation

My Workbook = 1st Workbook on list

Do While MyWorkbook <> “”

Workbooks.Open Filename:= MyWorkbook eg. "c:\My Docs\book1.xls"

Sheets("Period 1").Select
ActiveSheet.Name = "Period 2"

Activeworkbook.Save
Activeworkbook.Close


MyWorkbook = The next workbook

Loop


Then create the command button and call the above routine from it.

Regards

Carlos


Related articles

· Company Roles in Visual Basic Training
· What Is Microsoft Excel VBA and How Can It Help You Work Smarter?
· Should You Send Managers To VBA Training?
· Visual Basic Returns To The Macintosh
· How To Find A Good VB For Access Trainer

Vba tip:

Add A New Sheet at the end of the Workbook

To add a new sheet at the end of the workbook you need to count the sheets in the workbook using:

Sheets.Count

Then use this value as the rank of the sheet after which you want to add the new sheet:

Sheets.Add After:=Sheets(Sheets.Count)

View all VBA hints and tips

Rate this page:
4.0/5 (3 votes cast)
Institute of IT Training - Accredited Training Provider Microsoft Certified Partner
microsoft office
Microsoft Office Specialist Authorised Testing Centre (MOS and MCAS)

Prodigy Platinum Learning Partner

Institute of IT Training - Accredited Training Provider Association of Computer Trainers Valid HTML 4.01 Transitional
Valid CSS Markup

secure online payments - visa - mastercard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Training by application Main information pages See also

Access courses
DreamWeaver courses
Excel courses
MS Project courses
Outlook courses
PowerPoint courses
VBA courses
Word courses
(more...)

Public scheduled courses
On-site training
Closed company courses

Microsoft Office training
Pricing and availability
Training schedule
Training venues

Access training
Dreamweaver training
Excel training
MS Project training
PowerPoint training

London Computer Training
Computer Training London

Microsoft Access training
Microsoft Excel training
Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training

Time Management Course London

Interested in Access training? Please see the following pages:
microsoft access courses · microsoft training access course
microsoft+access+training · access courses in london

Training Information

Training Articles

AddThis Social Bookmark Button What's this?
Add to Del.icio.us Add to Facebook Add to Digg Add to Reddit Add to Google Add to Yahoo Add to Diigo Add to Mr. Wong Add to Linkarena Add to Power Oldie Add to Folkd Add to Jumptags Add to Upchuckr Add to Simpy Add to StumbleUpon Add to Slashdot Add to Netscape Add to Furl Add to Spurl Add to Blinklist Add to Blogmarks Add to Technorati Add to Newsvine Add to Blinkbits Add to Ma.Gnolia Add to Smarking Add to Netvouz