View Single Post
  #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