ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cells.Find Bug that's very strange (https://www.excelbanter.com/excel-programming/399855-cells-find-bug-thats-very-strange.html)

Carl

Cells.Find Bug that's very strange
 
I hope someone can explain this as we're stratching our heads here.

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?
When I stop the macro and go in to the workbook and hit Ctrl+F the date has
already been pasted in. If I simply press Find Next it finds it no problem.
So why does the macro stop before doing that? It is pointing at the correct
workbook and activating it so its no that.

Any help would be much appreciated.

Smallweed

Cells.Find Bug that's very strange
 
You might want to paste your code into the thread so we can have a go at
debugging it.

Possibilities: you've put quotes around the date when you don't need to; you
haven't included every argument the Find code needs (try re-recording a macro
finding a sample date and use the whole of that line).



"carl" wrote:

I hope someone can explain this as we're stratching our heads here.

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?
When I stop the macro and go in to the workbook and hit Ctrl+F the date has
already been pasted in. If I simply press Find Next it finds it no problem.
So why does the macro stop before doing that? It is pointing at the correct
workbook and activating it so its no that.

Any help would be much appreciated.


Tim Zych

Cells.Find Bug that's very strange
 
Try Cells.Find(CDate(strCurrentDate))

"carl" wrote in message
...
I hope someone can explain this as we're stratching our heads here.

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?
When I stop the macro and go in to the workbook and hit Ctrl+F the date
has
already been pasted in. If I simply press Find Next it finds it no
problem.
So why does the macro stop before doing that? It is pointing at the
correct
workbook and activating it so its no that.

Any help would be much appreciated.




Peter T

Cells.Find Bug that's very strange
 
Did you sort out your problem, if your date system is International I rather
suspect you didn't.

Regards,
Peter T

"carl" wrote in message
...
I hope someone can explain this as we're stratching our heads here.

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?
When I stop the macro and go in to the workbook and hit Ctrl+F the date

has
already been pasted in. If I simply press Find Next it finds it no

problem.
So why does the macro stop before doing that? It is pointing at the

correct
workbook and activating it so its no that.

Any help would be much appreciated.





All times are GMT +1. The time now is 12:00 AM.

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