Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default sheet namimg macro

I have a set of worksheets (200) that all have the same name, and they all
need to be changed to a name that is in the same cell address. The sheet
names are all 4631 and in cell A2 in every sheet is the full name ex.
"4631-02-09"

I am wondering if there is a way a macro can do this?


Todd
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default sheet namimg macro


I can't guarantee success but someting along the lines of the below
should work:

Dim OriginalName as String
Dim NewName as String

For x = 1 To ThisWorkbook.Worksheets.Count
OriginalName=ActiveSheet.Name
NewName = OriginalName & Range("A1").Value
ActiveSheet.Name = NewName
Next x

Change the Range("A1") to be the range of whatever the common cell is
and if needed change this formula so it puts the original name etc. in
a different order.

Should work.


--
Adamaths
------------------------------------------------------------------------
Adamaths's Profile: http://www.excelforum.com/member.php...o&userid=31580
View this thread: http://www.excelforum.com/showthread...hreadid=512790

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default sheet namimg macro

Thank you! that works wonderfully.

"Adamaths" wrote:


I can't guarantee success but someting along the lines of the below
should work:

Dim OriginalName as String
Dim NewName as String

For x = 1 To ThisWorkbook.Worksheets.Count
OriginalName=ActiveSheet.Name
NewName = OriginalName & Range("A1").Value
ActiveSheet.Name = NewName
Next x

Change the Range("A1") to be the range of whatever the common cell is
and if needed change this formula so it puts the original name etc. in
a different order.

Should work.


--
Adamaths
------------------------------------------------------------------------
Adamaths's Profile: http://www.excelforum.com/member.php...o&userid=31580
View this thread: http://www.excelforum.com/showthread...hreadid=512790


  #4   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default sheet namimg macro

I don't understand the point of the loop. It looks like you are changing the
name of the active sheet over and over. You'd have to activate each sheet at
the beginning of the code (in order to process every worksheet in the
workbook) or change ActiveSheet to Worksheets(x) (and fully qualify the
range as Worksheets(x).Range("A1"). A For/Each loop would also work:

Dim WkSht As Worksheet
For each WkSht in Worksheets
WkSht.Name = WkSht.Name & WkSht.Range("A1").Value
Next WkSht




"Adamaths" wrote:


I can't guarantee success but someting along the lines of the below
should work:

Dim OriginalName as String
Dim NewName as String

For x = 1 To ThisWorkbook.Worksheets.Count
OriginalName=ActiveSheet.Name
NewName = OriginalName & Range("A1").Value
ActiveSheet.Name = NewName
Next x

Change the Range("A1") to be the range of whatever the common cell is
and if needed change this formula so it puts the original name etc. in
a different order.

Should work.


--
Adamaths
------------------------------------------------------------------------
Adamaths's Profile: http://www.excelforum.com/member.php...o&userid=31580
View this thread: http://www.excelforum.com/showthread...hreadid=512790


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to lookup a sheet, number, then display in origonal sheet abbsy3 New Users to Excel 3 November 9th 10 12:19 PM
Return to Current Sheet in On (sheet activate) event macro Paul Moles Excel Programming 1 March 27th 05 03:16 PM
2 questions, copying data from sheet to sheet and assigning macro Boris Excel Worksheet Functions 0 December 16th 04 06:11 PM
How to create a Macro to Copy Information in one sheet to another sheet. poppy Excel Programming 3 July 28th 04 07:26 AM
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet arunjoshi[_5_] Excel Programming 1 May 2nd 04 03:50 PM


All times are GMT +1. The time now is 09:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"