![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 4
|
My column A is a list of dates for the whole year, i need to write a macro that will automatically move the cursor to the current date, any ideas please.
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Allentown, PA
Posts: 2,510
|
This one, though recorded will work. In Sheet2!A1, I wrote =Today()
This macro goes to Sheet2!A1, copies the date, then finds it in column A of Sheet1. Sub Macro3() Application.ScreenUpdate = False Sheets("Sheet2").Select Selection.Copy Sheets("Sheet1").Select Cells.Find(What:="02/24/2002", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _ MatchCase:=False).Activate Application.ScreenUpdating = True End Sub I recorded it then added screen updating. Might be an easier way.
__________________
~Anne Troy |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Perth Australia
Posts: 1,567
|
Hi
If your date is a value (ie not =today() or now()) then you can use this Cells.Find(What:=Date, After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _ MatchCase:=False).Activate End Sub Derek [ This Message was edited by: Derek on 2002-02-24 17:25 ] [ This Message was edited by: Derek on 2002-02-24 17:29 ] |
|
|
|
|
|
#4 |
|
New Member
Join Date: Feb 2002
Location: Bloomington, MN
Posts: 16
|
You could try this as well.
Sub GoToNow() Range("A1").Select While ActiveCell.Value <> Int(Now) ActiveCell.Offset(1, 0).Select Wend End Sub Jay |
|
|
|
|
|
#5 |
|
Join Date: Feb 2002
Posts: 39
|
Or more simply :-
Columns(1).Find(What:=Date, After:=[A65536]).Select |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Location: Perth Australia
Posts: 1,567
|
Autolycus
That a neat bit of code. Is there any way you can select today's date regardless of whether it is a value or the result of a formula, eg =today(). I can only seem to do one or the other but not both. regards Derek |
|
|
|
|
|
#7 | |
|
Join Date: Feb 2002
Posts: 39
|
Quote:
Columns(1).Find(What:=Format(Date, "d-mmm-yy"), After:=[A65536]).Select Or whatever date format in in column 1. |
|
|
|
|
|
|
#8 |
|
Join Date: Feb 2002
Posts: 39
|
Correction. Should read :-
Columns(1).Find(What:=Format(Date, "d-mmm-yy"), After:=[A65536], LookIn:=xlValues).Select |
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Feb 2002
Location: Perth Australia
Posts: 1,567
|
Autolycus
Works great! Many thanks Derek |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|