Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Rename Sheets based on date range

Hi All,

I would really appreciate some help with the following:

The first sheet in my workbook is called "Control".
The second sheet is called "A"
The last sheet is called "B"
In between sheets "A" and "B" are additional worksheets, one for
everyday of a month for example May 1 through to May 31.
On the "Control" worksheet I have starting in cell A2 the date
May 1 followed by May 2 etc.

What I need is some VBA code that will allow me to rename
all the worksheets that are in-between the "A" and "B" worksheets
with the list of dates that appear on the "Control" worksheet.

In essence as the user enters a new date for example June 1 in
A2 on the Control worksheet and drags the date down the column until it
reaches June 30,
all the sheets between "A" and "B" need to be updated.

Any ideas or suggestions on how to accomplish the above?

Thanks,

Steve



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Rename Sheets based on date range

Steve,

You don't have to drag the names down, all you need is a start date in A2

Sub RenameSheets()
Dim i As Long
Dim sh As Worksheet
Dim dte As Date
Dim dte1 As Date

If IsDate(Worksheets("Control").Range("A2").Value) Then
dte1 = CDate(Worksheets("Control").Range("A2").Value)
dte = dte1
For Each sh In ActiveWorkbook.Worksheets
If sh.Name < "Control" And sh.Name < "A" And _
sh.Name < "B" Then
If Month(dte) = Month(dte1) Then
sh.Name = Format(dte, "mmm d")
sh.Visible = xlSheetVisible
dte = dte + 1
Else
sh.Visible = xlSheetHidden
End If
End If
Next sh
Else
MsgBox "Start position invalid"
End If
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steve" wrote in message
news:%5jaf.389372$oW2.362335@pd7tw1no...
Hi All,

I would really appreciate some help with the following:

The first sheet in my workbook is called "Control".
The second sheet is called "A"
The last sheet is called "B"
In between sheets "A" and "B" are additional worksheets, one for
everyday of a month for example May 1 through to May 31.
On the "Control" worksheet I have starting in cell A2 the date
May 1 followed by May 2 etc.

What I need is some VBA code that will allow me to rename
all the worksheets that are in-between the "A" and "B" worksheets
with the list of dates that appear on the "Control" worksheet.

In essence as the user enters a new date for example June 1 in
A2 on the Control worksheet and drags the date down the column until it
reaches June 30,
all the sheets between "A" and "B" need to be updated.

Any ideas or suggestions on how to accomplish the above?

Thanks,

Steve





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Rename Sheets based on date range

Wow Bob, the code works great!
Thanks again for your help.

Cheers,

Steve



*** Sent via Developersdex http://www.developersdex.com ***
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
count a value in a date range based on a date in another workshee. marsjune68 Excel Worksheet Functions 4 April 9th 09 10:31 PM
Copying rows from 2 sheets to a new worksheet based on date criter Phill_Morgan Excel Discussion (Misc queries) 9 August 29th 07 08:03 AM
Rename file based on current date wira Excel Programming 1 April 29th 05 10:37 AM
Add Sheets and rename GregR Excel Discussion (Misc queries) 13 February 13th 05 10:56 PM
Find date and copy range based on that date avzundert Excel Programming 2 November 25th 04 10:31 AM


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