Focus on a cell based on date

D

dave.castle

I would like to have Excel 2003 on open move the focus to a cell
within a column based on the date opened so it reduces the need to
scroll down to find that date?
 
D

Dave

Hi,
Put this code in the workbook section of the VBE.

Private Sub Workbook_Open()
Z = 1
Y = 1
Do Until Cells(Z, Y) = Date
Z = Z + 1
Loop
Cells(Z, Y).Select
End Sub

If your dates are not in column A, change the value of Y in the 2nd line to
suit your data. (Column A=1, Column B=2, etc)
Regards - Dave.
 
F

Fred Smith

When you save the file, make sure the focus is on the cell you want. Excel
will preserve the focus on reopen.

Regards,
Fred.
 
J

Jarek Kujawa

in ThisWorkbook module put the following code

Private Sub Workbook_Open()
Dim l As Double
Range("A1:A10000").Select
l = DateSerial(Year(Now()), Month(Now()), Day(Now()))
k = Application.WorksheetFunction.Match(l, Selection, 0)
Cells(k, 1).Select
End Sub
 

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

Top