Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

find error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
anon - 20 Jan 2008 11:36 GMT
Hi,

I have this code and 2 problems;

Sheets("calendar").Activate
Dim foundcell As Range
Dim this
this = activecell.Value
Debug.Print this
Set foundcell = cells.find(what:=this, After:=activecell,
LookIn:=xlFormulas, LookAt _
       :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
       True)
    If foundcell Is Nothing Then
    foundcell.Activate

As a test i have typed cow in 2 cells, and run the code with the first
"cow" cell selected.

The code errors on the foundcell.activate, run time error '91', object
variable or with block variable not set. It is obviously finding the
second "cow" but will not select it.

My second problem is if i change the cell vaues from cow to dates eg,
01/01/2008 the find does not work at all.

Thanks,
anon - 20 Jan 2008 11:43 GMT
Apologies, I have adjusted my code so it is now correct and I no
longer get the error;

>      If not foundcell Is Nothing Then
>      foundcell.Activate

However why is my find not finding?! I can see plain as day the values
are there however it is not finding them.
JLGWhiz - 20 Jan 2008 14:39 GMT
It is possible that the setting MatchCase:= True could be the culprit.  If
your What is not the same case as the target cells, then it will not return
them.

> Apologies, I have adjusted my code so it is now correct and I no
> longer get the error;
[quoted text clipped - 4 lines]
> However why is my find not finding?! I can see plain as day the values
> are there however it is not finding them.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.