LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 361
Default Cells.Find bug that's very strange

I have named a string variable strCurrentDate that concatenates data together
to form the following date format: dd/mm/yyyy. What it is then meant to do is
go to a workbook and find that date in that format. So for example
01/06/2007. The macro is getting as far as activating the workbook and
putting the date in the find function but is then coming back with:

Run-time error '91'
Object variable or with block variable not set

What is happening here? Why can't it find the date that I'm looking for?

My line of code is:

Cells.Find(strCurrentDate).Activate

That is all. When the macro pauses due to the bug I can hover over the
strCurrentDate and it will show me the correct date (01/07/2007 for example)
so there's nothing wrong with my variable. That is the exact same date
format that I need to find in the workbook. When I stop the macro I can go
in to the workbook and hit Ctrl+F and 01/07/2007 will already be in the find
box. Hitting Find Next will find the correct cell. So why isn't the macro
doing it for me.

Tim Zych told me yesterday to try:

Cells.Find (CDate(strCurrentDate))

I tried that code but it seems to change the format of the date to the
American format and it doesn't find the cell. But it doesn't stop the macro
with a bug either so maybe you're on the right lines. But when I go to the
workbook and hit Ctrl+F the date in the find box is 7/1/2006 rather than the
way I wanted it as 01/07/2007. So it prevents the bug but doesn't find the
correct cell because the date format has been changed to the wrong format
from the correct format.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cells.Find Bug that's very strange carl Excel Programming 3 October 24th 07 09:39 PM
find and replace macro strange behaviour Nicawette Excel Discussion (Misc queries) 3 June 13th 06 08:49 PM
Strange AutoProtecting of cells Darin Kramer Excel Programming 0 March 2nd 05 09:27 AM
What is this Strange Characet? Find/Replace D[_6_] Excel Programming 12 November 25th 04 06:33 AM
Strange results using .FIND in Excel VBA Tom Ogilvy Excel Programming 0 August 6th 03 05:59 PM


All times are GMT +1. The time now is 01:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"