![]() |
![]() |
|
|||||||
| 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 |
|
Board Regular
Join Date: May 2002
Posts: 91
|
Dim t As String
t = Format(Date, "dd/mm/yyyy") Cells.Find(What:=t, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _ .Activate |
|
|
|
|
|
#2 | |
|
Board Regular
Join Date: Apr 2002
Posts: 112
|
Quote:
Dim t As String t = Format(Date, "dd/mm/yyyy") Set c = Cells.Find(What:=t, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) If Not c Is Nothing Then cAddress = c.Address Range(cAddress).Activate End If |
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: May 2002
Posts: 91
|
it's not working.
any one has a solution i am trying to search a today's date in my excel sheet. can any one help |
|
|
|
|
|
#4 |
|
Join Date: Mar 2002
Posts: 372
|
Dim t As String
t = Format(Date, "dd/mm/yyyy") Cells.Find(What:=DateValue(t), After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _ .Activate |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: May 2002
Posts: 91
|
Jones,
it is giving type mismatch error. however i found this solution dt = date Cells.Find(What:=dt, After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate [ This Message was edited by: jkpd2000 on 2002-05-21 17:00 ] [ This Message was edited by: jkpd2000 on 2002-05-21 17:01 ] |
|
|
|
|
|
#6 |
|
Join Date: Mar 2002
Posts: 372
|
Glad you got it working.
However, don't understand why you got a type mismatch error. It works for me. Are you sure it wasn't a RunTime Error 91 ? Just for interest, either one of these should work. Note the difference in the code (i.e. the "What" bit) depending on the variable type declaration. Dim t As String t = Date Cells.Find(What:=DateValue(t), After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _ .Activate Dim t As Date t = Date Cells.Find(What:=t, After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: May 2002
Posts: 91
|
Hi jones,
Yes it is giving runtime error 91 with message object variable or with block variable not set. i dont know why. when i run today your code is not giving error of data type mismatch as i told in my previous mail. any way i got the solution, thanks for your code. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|