ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Focus on a cell based on date (https://www.excelbanter.com/excel-worksheet-functions/195412-focus-cell-based-date.html)

[email protected]

Focus on a cell based on date
 
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?

Dave

Focus on a cell based on date
 
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.

Fred Smith[_4_]

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

Regards,
Fred.

wrote in message
...
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?



Jarek Kujawa[_2_]

Focus on a cell based on date
 
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


All times are GMT +1. The time now is 02:12 PM.

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