Auto scroll to current date

  • Thread starter Thread starter scain2004
  • Start date Start date
S

scain2004

My worksheet is formatted like a calendar for a full year, i.e.

S M T W Th F S
1 2 3 4 5 6 7
....


Is there a way to auto scroll in Workbook_Open to the week of th
current date?

Thanks,
Stev
 
Steve,

The first day of 2004 was a Thursday.
Shouldn't your calendar heading then start with Thursday?

'-----------------------------------
Sub FindTheRow()
'Jim Cone 07/13/04
Dim lngRow As Long
Dim x As Date
Dim y As Date
Dim z As Double

'Find the serial number for Jan 01, 2004
x = DateSerial(2004, 1, 1)
'Find today's serial number
y = DateSerial(2004, Month(Date), Day(Date))
'Find the number of days elapsed so far this year.
z = y - x + 1

'Adjust lngRow for actual start row of calendar.
lngRow = 3
'Find the row on the worksheet with the current week _
'by dividing days elapsed by 7 and adding 3.
lngRow = lngRow + Int(z / 7)

'Go there
ActiveWindow.ScrollRow = lngRow
End Sub
'-----------------------------------

Regards,
Jim Cone
San Francisco, CA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top