![]() |
Macro to jump to today's date
Hi
I have an Excel spreadsheet which includes, in Col A, a list of all 365 days of the year. When opening the spreadsheet, using an auto_open macro, I would like the opening view to include today's date (perhaps a few rows down from the top). Can anyone please recommend which functions I need to use in the macro to make the spreadsheet open in this way. Many thanks, V |
Macro to jump to today's date
You could try Columns(1).find(Date,,xlvalues,xlwhole).select I've tried this sort of thing before and you can get problems because of date formats. -- mrice Research Scientist with many years of spreadsheet development experience ------------------------------------------------------------------------ mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931 View this thread: http://www.excelforum.com/showthread...hreadid=557685 |
Macro to jump to today's date
You can try to run this Victor
Sub Find_Todays_Date() Dim FindString As Date Dim rng As Range FindString = Date With Sheets("Sheet1").Range("A:A") Set rng = .Find(What:=FindString, _ After:=.Cells(.Cells.Count), _ LookIn:=xlFormulas, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not rng Is Nothing Then Application.Goto rng, True Else MsgBox "Nothing found" End If End With End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Victor Delta" wrote in message ... Hi I have an Excel spreadsheet which includes, in Col A, a list of all 365 days of the year. When opening the spreadsheet, using an auto_open macro, I would like the opening view to include today's date (perhaps a few rows down from the top). Can anyone please recommend which functions I need to use in the macro to make the spreadsheet open in this way. Many thanks, V |
Macro to jump to today's date
Try:
With Range("A:A") Set c = .Find(DateValue(Now()), LookIn:=xlValues) If Not c Is Nothing Then ActiveWindow.ScrollRow = c.Row - 3 End If End With this will position the dates 3 rows fom today. HTH "Victor Delta" wrote: Hi I have an Excel spreadsheet which includes, in Col A, a list of all 365 days of the year. When opening the spreadsheet, using an auto_open macro, I would like the opening view to include today's date (perhaps a few rows down from the top). Can anyone please recommend which functions I need to use in the macro to make the spreadsheet open in this way. Many thanks, V |
Macro to jump to today's date
Sub Macro1()
Dim lRow As Long lRow = Date - DateSerial(Year(Date), 1, 1) + 1 ActiveWindow.ScrollRow = lRow + 1 Cells(lRow, "A").Activate End Sub HTH -- AP "Victor Delta" a écrit dans le message de news: ... Hi I have an Excel spreadsheet which includes, in Col A, a list of all 365 days of the year. When opening the spreadsheet, using an auto_open macro, I would like the opening view to include today's date (perhaps a few rows down from the top). Can anyone please recommend which functions I need to use in the macro to make the spreadsheet open in this way. Many thanks, V |
Macro to jump to today's date
Why not just put this in the ThisWorkbook module?:
Private Sub Workbook_Open() ActiveSheet.Columns(1).Find(Date).Select End Sub -- David Victor Delta wrote Hi I have an Excel spreadsheet which includes, in Col A, a list of all 365 days of the year. When opening the spreadsheet, using an auto_open macro, I would like the opening view to include today's date (perhaps a few rows down from the top). Can anyone please recommend which functions I need to use in the macro to make the spreadsheet open in this way. Many thanks, V |
Macro to jump to today's date
Many thanks for all these helpful suggestions.
V |
Macro to jump to today's date
"Ron de Bruin" wrote in message
... You can try to run this Victor Sub Find_Todays_Date() Dim FindString As Date Dim rng As Range FindString = Date With Sheets("Sheet1").Range("A:A") Set rng = .Find(What:=FindString, _ After:=.Cells(.Cells.Count), _ LookIn:=xlFormulas, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not rng Is Nothing Then Application.Goto rng, True Else MsgBox "Nothing found" End If End With End Sub -- Regards Ron de Bruin http://www.rondebruin.nl Ron Many thanks - it works. However, what do I need to add to this to scroll up about 3 lines - i.e. so today's date is not right at the top? I've tried several VBA commands but they don't seem to work for me! Thanks, V |
Macro to jump to today's date
Try this
Application.Goto rng.Offset(-3, 0), True -- Regards Ron de Bruin http://www.rondebruin.nl "Victor Delta" wrote in message ... "Ron de Bruin" wrote in message ... You can try to run this Victor Sub Find_Todays_Date() Dim FindString As Date Dim rng As Range FindString = Date With Sheets("Sheet1").Range("A:A") Set rng = .Find(What:=FindString, _ After:=.Cells(.Cells.Count), _ LookIn:=xlFormulas, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not rng Is Nothing Then Application.Goto rng, True Else MsgBox "Nothing found" End If End With End Sub -- Regards Ron de Bruin http://www.rondebruin.nl Ron Many thanks - it works. However, what do I need to add to this to scroll up about 3 lines - i.e. so today's date is not right at the top? I've tried several VBA commands but they don't seem to work for me! Thanks, V |
Macro to jump to today's date
"Ron de Bruin" wrote in message
... Try this Application.Goto rng.Offset(-3, 0), True -- Regards Ron de Bruin http://www.rondebruin.nl Brilliant. Many thanks. V |
All times are GMT +1. The time now is 04:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com