Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Rename sheets

I want to save a 2004 file and modify it to use for this year, as I need some
of the data. There are 52 sheets in the current file labeled with 2004
Saturday week ending dates. I have code as follows that created the sheets
and labeled them. Since the sheets will already exist and be named when I
copy the file over, I wondered if there was a way to rename them with 2005
week ending dates. Any help would be greatly appreciated!

Dim i As Long
Dim dte As Date
dte = CDate("1 JAN 2005")
For i = 1 To 51
dte = dte + 7
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "WE " & Format(dte, "mmddyy")
Next
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Rename sheets

Dim ThisSheet as Worksheet

For Each ThisSheet in ThisWorkbook.Worksheets
ThisSheet.Name = Replace(ThisSheet.Name, "2004", "2005")
Next ThisSheet

"cottage6" wrote:

I want to save a 2004 file and modify it to use for this year, as I need some
of the data. There are 52 sheets in the current file labeled with 2004
Saturday week ending dates. I have code as follows that created the sheets
and labeled them. Since the sheets will already exist and be named when I
copy the file over, I wondered if there was a way to rename them with 2005
week ending dates. Any help would be greatly appreciated!

Dim i As Long
Dim dte As Date
dte = CDate("1 JAN 2005")
For i = 1 To 51
dte = dte + 7
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "WE " & Format(dte, "mmddyy")
Next
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Rename sheets

Assuming the sheets are in chronological order:

Dim s As Long
Dim Date1 As Date

Date1 = #1/3/2005#
For S = 1 To ThisWorkbook.Worksheets.Count
Worksheets(S).Name = UCase$(Format$(Date1,"D MMM YYYY")
Date1 = Date1 + 7
Next S

I used a constant for the starting date. Change that as needed.

On Thu, 3 Feb 2005 06:01:02 -0800, "cottage6"
wrote:

Thanks for the response. My problem is not only does the year change, but
the Saturday week ending dates will change as well. So I need to rename the
first sheet to 1 Jan 2005, then get the others to rename using that as an
example. Any ideas?

"K Dales" wrote:

Dim ThisSheet as Worksheet

For Each ThisSheet in ThisWorkbook.Worksheets
ThisSheet.Name = Replace(ThisSheet.Name, "2004", "2005")
Next ThisSheet

"cottage6" wrote:

I want to save a 2004 file and modify it to use for this year, as I need

some
of the data. There are 52 sheets in the current file labeled with 2004
Saturday week ending dates. I have code as follows that created the

sheets
and labeled them. Since the sheets will already exist and be named when

I
copy the file over, I wondered if there was a way to rename them with

2005
week ending dates. Any help would be greatly appreciated!

Dim i As Long
Dim dte As Date
dte = CDate("1 JAN 2005")
For i = 1 To 51
dte = dte + 7
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "WE " & Format(dte, "mmddyy")
Next
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Rename sheets

I see a missing parenthesis. Should be:

Worksheets(S).Name = UCase$(Format$(Date1,"D MMM YYYY"))

On Thu, 03 Feb 2005 17:05:57 -0600, Myrna Larson
wrote:

Assuming the sheets are in chronological order:

Dim s As Long
Dim Date1 As Date

Date1 = #1/3/2005#
For S = 1 To ThisWorkbook.Worksheets.Count
Worksheets(S).Name = UCase$(Format$(Date1,"D MMM YYYY")
Date1 = Date1 + 7
Next S

I used a constant for the starting date. Change that as needed.

On Thu, 3 Feb 2005 06:01:02 -0800, "cottage6"
wrote:

Thanks for the response. My problem is not only does the year change, but
the Saturday week ending dates will change as well. So I need to rename the
first sheet to 1 Jan 2005, then get the others to rename using that as an
example. Any ideas?

"K Dales" wrote:

Dim ThisSheet as Worksheet

For Each ThisSheet in ThisWorkbook.Worksheets
ThisSheet.Name = Replace(ThisSheet.Name, "2004", "2005")
Next ThisSheet

"cottage6" wrote:

I want to save a 2004 file and modify it to use for this year, as I need

some
of the data. There are 52 sheets in the current file labeled with 2004
Saturday week ending dates. I have code as follows that created the

sheets
and labeled them. Since the sheets will already exist and be named when

I
copy the file over, I wondered if there was a way to rename them with

2005
week ending dates. Any help would be greatly appreciated!

Dim i As Long
Dim dte As Date
dte = CDate("1 JAN 2005")
For i = 1 To 51
dte = dte + 7
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "WE " & Format(dte, "mmddyy")
Next
End Sub


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 of sheets by macro Harshad[_2_] Excel Discussion (Misc queries) 4 October 17th 08 01:09 PM
Auto Rename Excel Sheets in Workbook Kulin Shah Excel Worksheet Functions 12 December 25th 06 03:27 PM
TO RENAME & COLOR THE SHEETS Ashwini Excel Discussion (Misc queries) 1 September 11th 06 01:20 PM
Add Sheets and rename GregR Excel Discussion (Misc queries) 13 February 13th 05 10:56 PM
Macro to Rename Multiple Sheets Alan Excel Programming 1 January 9th 04 04:38 PM


All times are GMT +1. The time now is 04:07 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"