If error is coming it means your date not found in that sheet..
' On the Top on Module
On Error Goto Err:

'Before End sub Statement
Err:
If err.number<>0 then
Msgbox " Date Not Found",vbinformation
endif

-----Original Message-----
From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of Tom
Sent: Tuesday, July 26, 2011 9:45 AM
To: MS EXCEL AND VBA MACROS
Subject: $$Excel-Macros$$ Help with find date.

I want the macro below to accept any date that I enter in its input
box, e.g. 17/06/2011, and go and find it in the active worksheet. I
got an error message saying, "Object variable or With block variable
not set". Can anyone help me? Thanks.

Sub FindDate()
Dim myDate As Date ' possibly incorrect
myDate = Application.InputBox("What date are you looking for?",
Type:=1)
    Cells.Find(What:="myDate", After:=ActiveCell, LookIn:=xlFormulas,
_
        LookAt:=xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
End Sub

Tom

-- 
----------------------------------------------------------------------------
------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links :
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Reply via email to