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

Hello.
I have a spreadsheet that has a list of worksheets that are named certain
dates and I would like to create an event that when I open the file it goes
to that tab according to today's date. It seems fairly easy but I think that
I'm complicating the problem. Thanks for your help.
--
D
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Dates to Worksheets

You have to remember that the name of the worksheet is a string, but the date
function returns a string...

Sub FindSheet()

Sheets(CStr(Format(Date, "mmm d, yyyy"))).Select
End Sub

Something like that depending on the format of your sheet name... You will
also want to refer to it in your on open event...

HTH

"D" wrote:

Hello.
I have a spreadsheet that has a list of worksheets that are named certain
dates and I would like to create an event that when I open the file it goes
to that tab according to today's date. It seems fairly easy but I think that
I'm complicating the problem. Thanks for your help.
--
D

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Dates to Worksheets

Ok, but the tabs that are dates run from now until 12-26-05 and the tabs are
by weeks. So each week is a tab, and so on a day like 2-1-05 that would bring
up the 1-31-05 tab because it is from the week of 1-31-05 to 2-6-05. So that
day would bring up that worksheet. I would think that I would have to do a
loop of some sort or maybe an array? Any ideas? Help please!
Thanks,
D

"Jim Thomlinson" wrote:

You have to remember that the name of the worksheet is a string, but the date
function returns a string...

Sub FindSheet()

Sheets(CStr(Format(Date, "mmm d, yyyy"))).Select
End Sub

Something like that depending on the format of your sheet name... You will
also want to refer to it in your on open event...

HTH

"D" wrote:

Hello.
I have a spreadsheet that has a list of worksheets that are named certain
dates and I would like to create an event that when I open the file it goes
to that tab according to today's date. It seems fairly easy but I think that
I'm complicating the problem. Thanks for your help.
--
D

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Dates to Worksheets

You can probably use formulas found here to determine what the name of your
sheet is

http://www.cpearson.com/excel/DateTimeVBA.htm

Chip Pearson's page on VBA and Dates

--
Regards,
Tom Ogilvy

"D" wrote in message
...
Ok, but the tabs that are dates run from now until 12-26-05 and the tabs

are
by weeks. So each week is a tab, and so on a day like 2-1-05 that would

bring
up the 1-31-05 tab because it is from the week of 1-31-05 to 2-6-05. So

that
day would bring up that worksheet. I would think that I would have to do a
loop of some sort or maybe an array? Any ideas? Help please!
Thanks,
D

"Jim Thomlinson" wrote:

You have to remember that the name of the worksheet is a string, but the

date
function returns a string...

Sub FindSheet()

Sheets(CStr(Format(Date, "mmm d, yyyy"))).Select
End Sub

Something like that depending on the format of your sheet name... You

will
also want to refer to it in your on open event...

HTH

"D" wrote:

Hello.
I have a spreadsheet that has a list of worksheets that are named

certain
dates and I would like to create an event that when I open the file it

goes
to that tab according to today's date. It seems fairly easy but I

think that
I'm complicating the problem. Thanks for your help.
--
D



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Dates to Worksheets

go to the VBE and go to the Thisworkbook module of the workbook.

in the left dropdown select workbook and in the right, select Open (top of
the module dropdowns).

change the formatting or logic to produce the date related name of the sheet
you want to go to.

Private Sub Workbook_Open()
Dim sh as Worksheet
On error resume Next
set sh = ThisWorkbook.Worksheets(format(date,"yyyymmdd"))
On Error goto 0
if not sh is nothing then
sh.Activate
else
with thisworkbook
.worksheets(worksheets.count).Activate
End With
End if
End Sub

Chip Pearson's page on Event
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy



"D" wrote in message
...
Hello.
I have a spreadsheet that has a list of worksheets that are named certain
dates and I would like to create an event that when I open the file it

goes
to that tab according to today's date. It seems fairly easy but I think

that
I'm complicating the problem. Thanks for your help.
--
D





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Dates to Worksheets

Much better code than mine and a better description. Use this code instead....

"Tom Ogilvy" wrote:

go to the VBE and go to the Thisworkbook module of the workbook.

in the left dropdown select workbook and in the right, select Open (top of
the module dropdowns).

change the formatting or logic to produce the date related name of the sheet
you want to go to.

Private Sub Workbook_Open()
Dim sh as Worksheet
On error resume Next
set sh = ThisWorkbook.Worksheets(format(date,"yyyymmdd"))
On Error goto 0
if not sh is nothing then
sh.Activate
else
with thisworkbook
.worksheets(worksheets.count).Activate
End With
End if
End Sub

Chip Pearson's page on Event
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy



"D" wrote in message
...
Hello.
I have a spreadsheet that has a list of worksheets that are named certain
dates and I would like to create an event that when I open the file it

goes
to that tab according to today's date. It seems fairly easy but I think

that
I'm complicating the problem. Thanks for your help.
--
D




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
dates on worksheets Ann Excel Worksheet Functions 5 April 29th 10 04:45 PM
Need help with 52 worksheets that need dates entered Susan Excel Discussion (Misc queries) 2 September 24th 09 07:53 PM
Sequential dates across worksheets Mick B Excel Discussion (Misc queries) 4 May 22nd 08 05:34 PM
changing dates in worksheets - help LEOPARDSHIDEAWAY Excel Discussion (Misc queries) 1 July 26th 07 10:06 PM
Moving dates between worksheets SuperDad Excel Discussion (Misc queries) 3 February 23rd 05 07:35 PM


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