#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Sheet names

I already have a subroutine that copies my active sheet, takes the
copied sheet and changes it's name to today's date in the format mm-dd-
yyyy. What I'd like to do is make the date = this week's Monday. No
matter where I am in the week. So if it's Thursday, March 1, I'd like
the vb to name the sheet 02-26-2007 (which was Monday's date) If it's
Sunday, I'd like to use the previous Monday. SheetExist is the common
function found in many places here in the group and on several sites.
I know I only need to manipulate the first line here, but how?
Any help greatly appreciated...
Thanks.
Rob


today_date = Format(Date, "mm-dd-yyyy")
i = 0
If SheetExist(today_date) Then
Do
i = i + 1
Loop Until SheetExist(today_date & "(rev " & i & ")") = False
ActiveSheet.Copy After:=Sheet5
ActiveSheet.Name = today_date & "(rev " & i & ")"
MsgBox "There is already a sheet with today's date on it... This
will show a 'rev' and the rev #."
Else
Activesheet.Copy After:=Sheet5
ActiveSheet.Name = today_date
End If

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Sheet names

today_date = Format(Date, "mm-dd-yyyy") - Weekday(Date, vbTuesday)

"okrob" wrote:

I already have a subroutine that copies my active sheet, takes the
copied sheet and changes it's name to today's date in the format mm-dd-
yyyy. What I'd like to do is make the date = this week's Monday. No
matter where I am in the week. So if it's Thursday, March 1, I'd like
the vb to name the sheet 02-26-2007 (which was Monday's date) If it's
Sunday, I'd like to use the previous Monday. SheetExist is the common
function found in many places here in the group and on several sites.
I know I only need to manipulate the first line here, but how?
Any help greatly appreciated...
Thanks.
Rob


today_date = Format(Date, "mm-dd-yyyy")
i = 0
If SheetExist(today_date) Then
Do
i = i + 1
Loop Until SheetExist(today_date & "(rev " & i & ")") = False
ActiveSheet.Copy After:=Sheet5
ActiveSheet.Name = today_date & "(rev " & i & ")"
MsgBox "There is already a sheet with today's date on it... This
will show a 'rev' and the rev #."
Else
Activesheet.Copy After:=Sheet5
ActiveSheet.Name = today_date
End If


  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Sheet names

I think you need to change it slightly:

today_date = Format(Date - Weekday(Date, vbTuesday), "mm-dd-yyyy")


"Brad" wrote:

today_date = Format(Date, "mm-dd-yyyy") - Weekday(Date, vbTuesday)

"okrob" wrote:

I already have a subroutine that copies my active sheet, takes the
copied sheet and changes it's name to today's date in the format mm-dd-
yyyy. What I'd like to do is make the date = this week's Monday. No
matter where I am in the week. So if it's Thursday, March 1, I'd like
the vb to name the sheet 02-26-2007 (which was Monday's date) If it's
Sunday, I'd like to use the previous Monday. SheetExist is the common
function found in many places here in the group and on several sites.
I know I only need to manipulate the first line here, but how?
Any help greatly appreciated...
Thanks.
Rob


today_date = Format(Date, "mm-dd-yyyy")
i = 0
If SheetExist(today_date) Then
Do
i = i + 1
Loop Until SheetExist(today_date & "(rev " & i & ")") = False
ActiveSheet.Copy After:=Sheet5
ActiveSheet.Name = today_date & "(rev " & i & ")"
MsgBox "There is already a sheet with today's date on it... This
will show a 'rev' and the rev #."
Else
Activesheet.Copy After:=Sheet5
ActiveSheet.Name = today_date
End If


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Sheet names

On Mar 1, 7:29 pm, JMB wrote:
I think you need to change it slightly:

today_date = Format(Date - Weekday(Date, vbTuesday), "mm-dd-yyyy")



"Brad" wrote:
today_date = Format(Date, "mm-dd-yyyy") - Weekday(Date, vbTuesday)


"okrob" wrote:


I already have a subroutine that copies my active sheet, takes the
copied sheet and changes it's name to today's date in the format mm-dd-
yyyy. What I'd like to do is make the date = this week's Monday. No
matter where I am in the week. So if it's Thursday, March 1, I'd like
the vb to name the sheet 02-26-2007 (which was Monday's date) If it's
Sunday, I'd like to use the previous Monday. SheetExist is the common
function found in many places here in the group and on several sites.
I know I only need to manipulate the first line here, but how?
Any help greatly appreciated...
Thanks.
Rob


today_date = Format(Date, "mm-dd-yyyy")
i = 0
If SheetExist(today_date) Then
Do
i = i + 1
Loop Until SheetExist(today_date & "(rev " & i & ")") = False
ActiveSheet.Copy After:=Sheet5
ActiveSheet.Name = today_date & "(rev " & i & ")"
MsgBox "There is already a sheet with today's date on it... This
will show a 'rev' and the rev #."
Else
Activesheet.Copy After:=Sheet5
ActiveSheet.Name = today_date
End If- Hide quoted text -


- Show quoted text -


Thanks Brad and JMB... Worked great...

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
Sheet Referencing - autofilling sheet names Pat Excel Worksheet Functions 2 June 4th 09 03:50 AM
Cell names = sheet names Vince Excel Worksheet Functions 9 February 8th 08 03:59 PM
Using Sheet names & Workbook names in VBA coding Colin Foster[_5_] Excel Programming 5 July 7th 06 07:04 PM
I want to print out the sheet tabs (sheet names) Sundus Excel Worksheet Functions 3 February 23rd 05 08:34 PM
return all worksheet tab names and chart sheet tab names in report - an example DataFreakFromUtah Excel Programming 2 October 6th 04 08:09 PM


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