Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Rename first X number of worksheets predefined names

I have a template that populates based on the last 13 weeks of reports. I
have a worksheet for each week's report. The worksheets are named wk1, wk2,
wk3.....wk13. On a weekly basis, I plan to insert the latest report into a
new worksheet after wk13. Then I will delete wk1. At that point I will need
to rename wk2 to wk1, wk3 to wk2, etc. I would then end up with the latest
13 weeks again. The formula's in my template have references to the sheet
names, so that is why I'll need to rename them. So my question is this:

Is there some vba code that will rename the first 13 worksheets to
predifined names, but stop renameing worksheets once it's finished with the
13th? In my case, rename the first worksheet to "wk1", the second worksheet
to "wk2", etc. It would be great if I could do this with the push of a
button, instead of taking time to rename 13 worksheets each week.

Jeff
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Rename first X number of worksheets predefined names

Sub WorksheetLoop()
Dim wsName As String
This may get you started in the right direction
Test in a copy of you workbook.
Dim WS_Count As Integer
Dim I As Integer
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop.
For I = 1 To WS_Count
wsName = "wk" & I
On Error Resume Next
ActiveWorkbook.Worksheets(I).Name = wsName
Next I
End Sub

"goofy11" wrote:

I have a template that populates based on the last 13 weeks of reports. I
have a worksheet for each week's report. The worksheets are named wk1, wk2,
wk3.....wk13. On a weekly basis, I plan to insert the latest report into a
new worksheet after wk13. Then I will delete wk1. At that point I will need
to rename wk2 to wk1, wk3 to wk2, etc. I would then end up with the latest
13 weeks again. The formula's in my template have references to the sheet
names, so that is why I'll need to rename them. So my question is this:

Is there some vba code that will rename the first 13 worksheets to
predifined names, but stop renameing worksheets once it's finished with the
13th? In my case, rename the first worksheet to "wk1", the second worksheet
to "wk2", etc. It would be great if I could do this with the push of a
button, instead of taking time to rename 13 worksheets each week.

Jeff

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
rename category names rename category names Charts and Charting in Excel 3 December 17th 09 10:51 AM
Check if a predefined number of workbooks exist in a specific directory Ixtreme Excel Programming 4 January 2nd 07 04:35 PM
Rename files with variable names Robert_L_Ross Excel Programming 1 June 20th 06 06:52 PM
Rename Defined Names Sige Excel Worksheet Functions 3 January 13th 06 05:44 PM
Cycling through predefined worksheets Craig M Excel Programming 3 July 1st 04 07:58 AM


All times are GMT +1. The time now is 05:14 AM.

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

About Us

"It's about Microsoft Excel"