ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding the current date (https://www.excelbanter.com/excel-programming/291701-finding-current-date.html)

serge

Finding the current date
 
Hi,

I'm using the following code to activate the current date in a column:

Private Sub workbook_activate()
Range("a:a").Cells.Find(what:=Date, LookIn:=xlFormulas, _
MatchCase:=False).Activate
End Sub

IF A1= 17/02/2004
A2= 18/02/2004
A3= 18/12/2004

Then it activates cell A2 which is good.
But if A1= 17/02/2004
A2= 18/12/2004
A3= 18/02/2004
then it activates cell A2.
What's wrong in this code?


---
Message posted from http://www.ExcelForum.com/


Nick Cranham

Finding the current date
 
serge,
If you add the "LookAt:=xlWhole", works.

NickHK

"serge " wrote in message
...
Hi,

I'm using the following code to activate the current date in a column:

Private Sub workbook_activate()
Range("a:a").Cells.Find(what:=Date, LookIn:=xlFormulas, _
MatchCase:=False).Activate
End Sub

IF A1= 17/02/2004
A2= 18/02/2004
A3= 18/12/2004

Then it activates cell A2 which is good.
But if A1= 17/02/2004
A2= 18/12/2004
A3= 18/02/2004
then it activates cell A2.
What's wrong in this code?


---
Message posted from http://www.ExcelForum.com/




Nick Cranham

Finding the current date
 
Also, adding a sheet reference would be better, as you cannot be sure which
sheet will be active when you .Activate the workbook.

NickHK

"Nick Cranham" wrote in message
...
serge,
If you add the "LookAt:=xlWhole", works.

NickHK

"serge " wrote in message
...
Hi,

I'm using the following code to activate the current date in a column:

Private Sub workbook_activate()
Range("a:a").Cells.Find(what:=Date, LookIn:=xlFormulas, _
MatchCase:=False).Activate
End Sub

IF A1= 17/02/2004
A2= 18/02/2004
A3= 18/12/2004

Then it activates cell A2 which is good.
But if A1= 17/02/2004
A2= 18/12/2004
A3= 18/02/2004
then it activates cell A2.
What's wrong in this code?


---
Message posted from http://www.ExcelForum.com/







All times are GMT +1. The time now is 10:03 PM.

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