ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   go to today's date (https://www.excelbanter.com/excel-programming/354870-go-todays-date.html)

SheriTingle

go to today's date
 
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.

Dave Peterson

go to today's date
 
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

SheriTingle wrote:

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.


--

Dave Peterson


All times are GMT +1. The time now is 05:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com