Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Query on small piece of code

I have the following very simple piece of code as part of a macro:


Selection.Find(What:="01/08/2002", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate


Quite simply, in a row that is selected, the instruction is to activate the
cell where it finds the date shown.

I have recorded this through simply "doing a Ctrl+F" with the recorder
running, but when I run this macro to check it keeps failing.

Any ideas on what the problem is as it's driving me mad, I can't see what's
wrong.

Thanks in advance

Mike


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Query on small piece of code

I should say that the error message was as follows:

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

Thanks again for any help

Mike


"Mike" wrote in message
...
I have the following very simple piece of code as part of a macro:


Selection.Find(What:="01/08/2002", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate


Quite simply, in a row that is selected, the instruction is to activate

the
cell where it finds the date shown.

I have recorded this through simply "doing a Ctrl+F" with the recorder
running, but when I run this macro to check it keeps failing.

Any ideas on what the problem is as it's driving me mad, I can't see

what's
wrong.

Thanks in advance

Mike




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Query on small piece of code

Mike,

You'll get this error if the value is not found. Are you sure the
value is in the range?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Mike" wrote in message
...
I should say that the error message was as follows:

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

Thanks again for any help

Mike


"Mike" wrote in message
...
I have the following very simple piece of code as part of a

macro:


Selection.Find(What:="01/08/2002", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate


Quite simply, in a row that is selected, the instruction is

to activate
the
cell where it finds the date shown.

I have recorded this through simply "doing a Ctrl+F" with the

recorder
running, but when I run this macro to check it keeps

failing.

Any ideas on what the problem is as it's driving me mad, I

can't see
what's
wrong.

Thanks in advance

Mike






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Query on small piece of code

Hi Mike
you probably have no cells selected when you invoke this macro which
contains your search string.

--
Regards
Frank Kabel
Frankfurt, Germany

Mike wrote:
I have the following very simple piece of code as part of a macro:


Selection.Find(What:="01/08/2002", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate


Quite simply, in a row that is selected, the instruction is to
activate the cell where it finds the date shown.

I have recorded this through simply "doing a Ctrl+F" with the

recorder
running, but when I run this macro to check it keeps failing.

Any ideas on what the problem is as it's driving me mad, I can't see
what's wrong.

Thanks in advance

Mike


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Query on small piece of code

Chip

Thanks. Having thought about the value itself, I have just run it again
through the immediate window putting in the value "8/1/2002" and it now
works fine. The problem is that the date is actually formatted as a UK and
not American date. This seems to be the problem. This looks like it could
cause problems for me, is there any way of reverting all settings to a UK
setting, as it seems perhaps that with the visual basic it's running on a US
format, even if Excel itself isn't?

Regards

Mike


"Chip Pearson" wrote in message
...
Mike,

You'll get this error if the value is not found. Are you sure the
value is in the range?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Mike" wrote in message
...
I should say that the error message was as follows:

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

Thanks again for any help

Mike


"Mike" wrote in message
...
I have the following very simple piece of code as part of a

macro:


Selection.Find(What:="01/08/2002", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate


Quite simply, in a row that is selected, the instruction is

to activate
the
cell where it finds the date shown.

I have recorded this through simply "doing a Ctrl+F" with the

recorder
running, but when I run this macro to check it keeps

failing.

Any ideas on what the problem is as it's driving me mad, I

can't see
what's
wrong.

Thanks in advance

Mike










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Query on small piece of code

set rng = Selection.Find(What:=clng(cDate("01/08/2002")), _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)

if not rng is nothing then
rng.Select
Else
msgbox "Not found"
End if

--
Regards,
Tom Ogilvy


"Mike" wrote in message
...
I should say that the error message was as follows:

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

Thanks again for any help

Mike


"Mike" wrote in message
...
I have the following very simple piece of code as part of a macro:


Selection.Find(What:="01/08/2002", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate


Quite simply, in a row that is selected, the instruction is to activate

the
cell where it finds the date shown.

I have recorded this through simply "doing a Ctrl+F" with the recorder
running, but when I run this macro to check it keeps failing.

Any ideas on what the problem is as it's driving me mad, I can't see

what's
wrong.

Thanks in advance

Mike






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Query on small piece of code

cdate should respect your regional settings.

--
Regards,
Tom Ogilvy

"Mike" wrote in message
...
Chip

Thanks. Having thought about the value itself, I have just run it again
through the immediate window putting in the value "8/1/2002" and it now
works fine. The problem is that the date is actually formatted as a UK and
not American date. This seems to be the problem. This looks like it could
cause problems for me, is there any way of reverting all settings to a UK
setting, as it seems perhaps that with the visual basic it's running on a

US
format, even if Excel itself isn't?

Regards

Mike


"Chip Pearson" wrote in message
...
Mike,

You'll get this error if the value is not found. Are you sure the
value is in the range?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Mike" wrote in message
...
I should say that the error message was as follows:

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

Thanks again for any help

Mike


"Mike" wrote in message
...
I have the following very simple piece of code as part of a

macro:


Selection.Find(What:="01/08/2002", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate


Quite simply, in a row that is selected, the instruction is

to activate
the
cell where it finds the date shown.

I have recorded this through simply "doing a Ctrl+F" with the

recorder
running, but when I run this macro to check it keeps

failing.

Any ideas on what the problem is as it's driving me mad, I

can't see
what's
wrong.

Thanks in advance

Mike










  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Query on small piece of code

Cheers Tom and Chip - much appreciate the help

Mike


"Tom Ogilvy" wrote in message
...
set rng = Selection.Find(What:=clng(cDate("01/08/2002")), _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)

if not rng is nothing then
rng.Select
Else
msgbox "Not found"
End if

--
Regards,
Tom Ogilvy


"Mike" wrote in message
...
I should say that the error message was as follows:

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

Thanks again for any help

Mike


"Mike" wrote in message
...
I have the following very simple piece of code as part of a macro:


Selection.Find(What:="01/08/2002", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate


Quite simply, in a row that is selected, the instruction is to

activate
the
cell where it finds the date shown.

I have recorded this through simply "doing a Ctrl+F" with the recorder
running, but when I run this macro to check it keeps failing.

Any ideas on what the problem is as it's driving me mad, I can't see

what's
wrong.

Thanks in advance

Mike








Reply
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
Small Query - Urgent showry Excel Discussion (Misc queries) 2 February 26th 10 01:32 PM
Small Query Anil showreddy Excel Discussion (Misc queries) 2 August 4th 09 07:13 AM
Just A Small Code FARAZ QURESHI Excel Discussion (Misc queries) 1 December 24th 08 12:52 PM
Interpretation of a piece of code FARAZ QURESHI Excel Discussion (Misc queries) 3 December 30th 07 11:29 PM
What is wrong with this vba piece of code? Jo[_2_] Excel Discussion (Misc queries) 4 October 4th 07 05:01 PM


All times are GMT +1. The time now is 02:09 PM.

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

About Us

"It's about Microsoft Excel"