![]() |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 05:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com