go to today's date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi and thanks for the help. I am using Excel 2003. I have a spread sheet that
holds the date for every day of the year. I would like to create a macro that
takes me to the current date on the sheet every time I open the workbook.

I know that in Access that macro is named AutoExec and in Word it is called
AutoOpen but I don't know what to call it in Excel to automatically run the
macro when the workbook is opened.

I don't have any idea how to make the macro find the current date. If you
put code in here please go easy on me. I don't ever do any code. My worksheet
name is 2006. Thanks.
 
I'm guessing that the worksheet name is Sheet1 and the dates are in column A.

Option Explicit
Sub Auto_Open()

Dim Res As Variant
Dim Wks As Worksheet

Set Wks = Worksheets("sheet1")

With Wks
Res = Application.Match(CLng(Date), .Range("a:a"), 0)
If IsError(Res) Then
MsgBox "Date not found"
Else
Application.Goto Wks.Range("a:a")(Res), scroll:=True
End If
End With

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Back
Top