Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Evaluate Method Returns Type Mismatch

This is so strange I'm not sure how to ask.

I have a procedure that opens each workbook in a given folder. With
each workbook some code is applied. The workbook object and excel
instance are destroyed and then the loop goes to the next workbook,
etc.

I have this statement that is applied to each workbook:

CurrentRow = Evaluate("=MATCH(""" & Cell.Value & """,Survey_Questions,
0)+ROW(Survey_Questions)-1")

'Cell.Value is the string "Phone Support"
'Survey_Questions is a named range that contains as list of string
values, including "Phone Support"

So the formula would read:
=MATCH("Phone Support",Survey_Questions,0)+ROW(Survey_Questions)-1

This formula returns the row where the Cell.Value is located. However,
the statement produces a type mismatch error. If I run just the
formula in the Immediate window and then paste that into the worksheet
it works.

Why am I getting the type mismatch error.

Also, I know there are other ways to get the row. This is just an
example.

tod
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Evaluate Method Returns Type Mismatch

You missed a " in your """. It should be """" & Cell.Value & """". If in
doubt try using the character command:
Chr(34) & Cell.Value & Chr(34)
--
Charles Chickering

"A good example is twice the value of good advice."


"todtown" wrote:

This is so strange I'm not sure how to ask.

I have a procedure that opens each workbook in a given folder. With
each workbook some code is applied. The workbook object and excel
instance are destroyed and then the loop goes to the next workbook,
etc.

I have this statement that is applied to each workbook:

CurrentRow = Evaluate("=MATCH(""" & Cell.Value & """,Survey_Questions,
0)+ROW(Survey_Questions)-1")

'Cell.Value is the string "Phone Support"
'Survey_Questions is a named range that contains as list of string
values, including "Phone Support"

So the formula would read:
=MATCH("Phone Support",Survey_Questions,0)+ROW(Survey_Questions)-1

This formula returns the row where the Cell.Value is located. However,
the statement produces a type mismatch error. If I run just the
formula in the Immediate window and then paste that into the worksheet
it works.

Why am I getting the type mismatch error.

Also, I know there are other ways to get the row. This is just an
example.

tod

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Evaluate Method Returns Type Mismatch

After some more testing I can exlain the problem better (I think).

The error does not occur with the first workbook, but the second. It
returns error 2029 (#Name) with the named ranges, but error 2023
(#Ref) if I replace the named ranges in the formula with the actual
address. I "think" with the second workbook, the code in the statement
is still trying to reference the first workbook. I have the same names
in each of the workbooks.

Even though I empty all my global variables and destroy all of my
objects before cycling to the next workbook, I think something inside
the evaluate method is still referencing the previous workbook.

So... if my theory is correct, how can I get the code to look at the
newly-opened workbook instead of the one that was just closed?


tod



On Nov 20, 2:31 pm, Charles Chickering
wrote:
You missed a " in your """. It should be """" & Cell.Value & """". If in
doubt try using the character command:
Chr(34) & Cell.Value & Chr(34)
--
Charles Chickering

"A good example is twice the value of good advice."



"todtown" wrote:
This is so strange I'm not sure how to ask.


I have a procedure that opens each workbook in a given folder. With
each workbook some code is applied. The workbook object and excel
instance are destroyed and then the loop goes to the next workbook,
etc.


I have this statement that is applied to each workbook:


CurrentRow = Evaluate("=MATCH(""" & Cell.Value & """,Survey_Questions,
0)+ROW(Survey_Questions)-1")


'Cell.Value is the string "Phone Support"
'Survey_Questions is a named range that contains as list of string
values, including "Phone Support"


So the formula would read:
=MATCH("Phone Support",Survey_Questions,0)+ROW(Survey_Questions)-1


This formula returns the row where the Cell.Value is located. However,
the statement produces a type mismatch error. If I run just the
formula in the Immediate window and then paste that into the worksheet
it works.


Why am I getting the type mismatch error.


Also, I know there are other ways to get the row. This is just an
example.


tod- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Evaluate Method Returns Type Mismatch

After some more testing I can exlain the problem better (I think).

The error does not occur with the first workbook, but the second. It
returns error 2029 (#Name) with the named ranges, but error 2023
(#Ref) if I replace the named ranges in the formula with the actual
address. I "think" with the second workbook, the code in the statement
is still trying to reference the first workbook. I have the same names
in each of the workbooks.

Even though I empty all my global variables and destroy all of my
objects before cycling to the next workbook, I think something inside
the evaluate method is still referencing the previous workbook.

So... if my theory is correct, how can I get the code to look at the
newly-opened workbook instead of the one that was just closed?


tod



On Nov 20, 2:31 pm, Charles Chickering
wrote:
You missed a " in your """. It should be """" & Cell.Value & """". If in
doubt try using the character command:
Chr(34) & Cell.Value & Chr(34)
--
Charles Chickering

"A good example is twice the value of good advice."



"todtown" wrote:
This is so strange I'm not sure how to ask.


I have a procedure that opens each workbook in a given folder. With
each workbook some code is applied. The workbook object and excel
instance are destroyed and then the loop goes to the next workbook,
etc.


I have this statement that is applied to each workbook:


CurrentRow = Evaluate("=MATCH(""" & Cell.Value & """,Survey_Questions,
0)+ROW(Survey_Questions)-1")


'Cell.Value is the string "Phone Support"
'Survey_Questions is a named range that contains as list of string
values, including "Phone Support"


So the formula would read:
=MATCH("Phone Support",Survey_Questions,0)+ROW(Survey_Questions)-1


This formula returns the row where the Cell.Value is located. However,
the statement produces a type mismatch error. If I run just the
formula in the Immediate window and then paste that into the worksheet
it works.


Why am I getting the type mismatch error.


Also, I know there are other ways to get the row. This is just an
example.


tod- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Evaluate Method Returns Type Mismatch

After some more testing I can exlain the problem better (I think).

The error does not occur with the first workbook, but the second. It
returns error 2029 (#Name) with the named ranges, but error 2023
(#Ref) if I replace the named ranges in the formula with the actual
address. I "think" with the second workbook, the code in the statement
is still trying to reference the first workbook. I have the same names
in each of the workbooks.

Even though I empty all my global variables and destroy all of my
objects before cycling to the next workbook, I think something inside
the evaluate method is still referencing the previous workbook.

So... if my theory is correct, how can I get the code to look at the
newly-opened workbook instead of the one that was just closed?


tod



On Nov 20, 2:31 pm, Charles Chickering
wrote:
You missed a " in your """. It should be """" & Cell.Value & """". If in
doubt try using the character command:
Chr(34) & Cell.Value & Chr(34)
--
Charles Chickering

"A good example is twice the value of good advice."



"todtown" wrote:
This is so strange I'm not sure how to ask.


I have a procedure that opens each workbook in a given folder. With
each workbook some code is applied. The workbook object and excel
instance are destroyed and then the loop goes to the next workbook,
etc.


I have this statement that is applied to each workbook:


CurrentRow = Evaluate("=MATCH(""" & Cell.Value & """,Survey_Questions,
0)+ROW(Survey_Questions)-1")


'Cell.Value is the string "Phone Support"
'Survey_Questions is a named range that contains as list of string
values, including "Phone Support"


So the formula would read:
=MATCH("Phone Support",Survey_Questions,0)+ROW(Survey_Questions)-1


This formula returns the row where the Cell.Value is located. However,
the statement produces a type mismatch error. If I run just the
formula in the Immediate window and then paste that into the worksheet
it works.


Why am I getting the type mismatch error.


Also, I know there are other ways to get the row. This is just an
example.


tod- Hide quoted text -


- Show quoted text -




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Evaluate Method Returns Type Mismatch

Tod, can you post more of your code? Also as a general means of debugging,
have you paused when the error occurs and used the immediate window to see
what all the objects return?
--
Charles Chickering

"A good example is twice the value of good advice."


"todtown" wrote:

After some more testing I can exlain the problem better (I think).

The error does not occur with the first workbook, but the second. It
returns error 2029 (#Name) with the named ranges, but error 2023
(#Ref) if I replace the named ranges in the formula with the actual
address. I "think" with the second workbook, the code in the statement
is still trying to reference the first workbook. I have the same names
in each of the workbooks.

Even though I empty all my global variables and destroy all of my
objects before cycling to the next workbook, I think something inside
the evaluate method is still referencing the previous workbook.

So... if my theory is correct, how can I get the code to look at the
newly-opened workbook instead of the one that was just closed?


tod



On Nov 20, 2:31 pm, Charles Chickering
wrote:
You missed a " in your """. It should be """" & Cell.Value & """". If in
doubt try using the character command:
Chr(34) & Cell.Value & Chr(34)
--
Charles Chickering

"A good example is twice the value of good advice."



"todtown" wrote:
This is so strange I'm not sure how to ask.


I have a procedure that opens each workbook in a given folder. With
each workbook some code is applied. The workbook object and excel
instance are destroyed and then the loop goes to the next workbook,
etc.


I have this statement that is applied to each workbook:


CurrentRow = Evaluate("=MATCH(""" & Cell.Value & """,Survey_Questions,
0)+ROW(Survey_Questions)-1")


'Cell.Value is the string "Phone Support"
'Survey_Questions is a named range that contains as list of string
values, including "Phone Support"


So the formula would read:
=MATCH("Phone Support",Survey_Questions,0)+ROW(Survey_Questions)-1


This formula returns the row where the Cell.Value is located. However,
the statement produces a type mismatch error. If I run just the
formula in the Immediate window and then paste that into the worksheet
it works.


Why am I getting the type mismatch error.


Also, I know there are other ways to get the row. This is just an
example.


tod- Hide quoted text -


- Show quoted text -



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Evaluate Method Returns Type Mismatch

Sound like your problem is unqualified references (which default to the
active sheet).
Try either expanding all the references to include the workbook and
worksheet or using Worksheet.Evaluate rather than Application.Evaluate,
which will then force the unqualified references to resolve to whatever
Worksheet you reference in Worksheet.Evaluate.

There are some more quirks of the Evaluate method listed at
http://www.decisionmodels.com/calcsecretsh.htm

HTH
Charles
_________________________________________
UK Cambridge XL Users Conference 29-30 Nov
http://www.exceluserconference.com/UKEUC.html

"todtown" wrote in message
...
After some more testing I can exlain the problem better (I think).

The error does not occur with the first workbook, but the second. It
returns error 2029 (#Name) with the named ranges, but error 2023
(#Ref) if I replace the named ranges in the formula with the actual
address. I "think" with the second workbook, the code in the statement
is still trying to reference the first workbook. I have the same names
in each of the workbooks.

Even though I empty all my global variables and destroy all of my
objects before cycling to the next workbook, I think something inside
the evaluate method is still referencing the previous workbook.

So... if my theory is correct, how can I get the code to look at the
newly-opened workbook instead of the one that was just closed?


tod



On Nov 20, 2:31 pm, Charles Chickering
wrote:
You missed a " in your """. It should be """" & Cell.Value & """". If in
doubt try using the character command:
Chr(34) & Cell.Value & Chr(34)
--
Charles Chickering

"A good example is twice the value of good advice."



"todtown" wrote:
This is so strange I'm not sure how to ask.


I have a procedure that opens each workbook in a given folder. With
each workbook some code is applied. The workbook object and excel
instance are destroyed and then the loop goes to the next workbook,
etc.


I have this statement that is applied to each workbook:


CurrentRow = Evaluate("=MATCH(""" & Cell.Value & """,Survey_Questions,
0)+ROW(Survey_Questions)-1")


'Cell.Value is the string "Phone Support"
'Survey_Questions is a named range that contains as list of string
values, including "Phone Support"


So the formula would read:
=MATCH("Phone Support",Survey_Questions,0)+ROW(Survey_Questions)-1


This formula returns the row where the Cell.Value is located. However,
the statement produces a type mismatch error. If I run just the
formula in the Immediate window and then paste that into the worksheet
it works.


Why am I getting the type mismatch error.


Also, I know there are other ways to get the row. This is just an
example.


tod- Hide quoted text -


- Show quoted text -




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Evaluate Method Returns Type Mismatch

On Nov 20, 4:13 pm, "Charles Williams"
wrote:
Sound like your problem is unqualified references (which default to the
active sheet).


That was it!! I simply put my Excel object variable in front of
Evaluate, like:

objXL.Evaluate.......

and that took care of it.

thanx,
tod
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Evaluate Method Returns Type Mismatch

On Nov 20, 4:13 pm, "Charles Williams"
wrote:
Sound like your problem is unqualified references (which default to the
active sheet).


That was it!! I simply put my Excel object variable in front of
Evaluate, like:

objXL.Evaluate.......

and that took care of it.

thanx,
tod
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Evaluate Method Returns Type Mismatch

On Nov 20, 4:13 pm, "Charles Williams"
wrote:
Sound like your problem is unqualified references (which default to the
active sheet).


That was it!! I simply put my Excel object variable in front of
Evaluate, like:

objXL.Evaluate.......

and that took care of it.

thanx,
tod
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
Evaluate Method Returns Type Mismatch todtown Excel Programming 0 November 20th 07 07:26 PM
Evaluate Method Returns Type Mismatch todtown Excel Programming 0 November 20th 07 07:26 PM
Type mismatch error in Find method JLGWhiz Excel Programming 1 April 9th 07 03:51 AM
Type Mismatch Error when using InputBox Method Anolan Excel Programming 1 November 22nd 05 07:35 PM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM


All times are GMT +1. The time now is 11:49 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"