going to Today's date with a macro

J

Jim

Hi
I have a database with ten years of dates in column A. Is there a
simple macro I could write that would go to the row with today's date. I
just want to be able to click on a "Today" button that will run the macro
that goes to the row containing today's date. Thanks Jim
 
G

Guest

hi
here's the code.
Private Sub CommandButton1_Click()
Dim d As Date
d = Date 'Today's date
Cells.Find(What:=d, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate
End Sub

But i don't know if you want it in a command button on the sheet or an icon
button on your tool bar. I would recomend a command button on the sheet
because command buttons follow the file. icon buttons don't.
the above is for a command button on the sheet. if you want an icon button,
then create your icon. paste the code in a standard module. change the name
to...oh.. sub FindToday() then attach the module to the icon.

the above worked on my machine. running xp.
hope this helped
Regards
FSt1
 

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

Similar Threads


Top