Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Formula will not evaluate in VBA

I was wishing to test if duplicate names appeared within 2 columns and
take actions accordingly.

Here is the formula I was trying to evaluate.

=((A2:A2000="string")*(B2:B2000="string2"))

When I type the function in manually on an excel sheet I get a
value of 1 which is what I'm desiring.

However, when I use the Evaluate function in VBA a Type mismatch error
is thrown at me.

If Evaluate("=((A2:A2000=" & """" & "string" & """" & ")*(B2:B2000=" _
& """" & "string2" & """" & "))") Then

.....


I can set the evaluate function to a variable, but only if its defined
as a variant and still I can't do anything with the results.

Help would be greatly appreciated. Thanks in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Formula will not evaluate in VBA

maybe just adding sum() to your expression???



" wrote:

I was wishing to test if duplicate names appeared within 2 columns and
take actions accordingly.

Here is the formula I was trying to evaluate.

=((A2:A2000="string")*(B2:B2000="string2"))

When I type the function in manually on an excel sheet I get a
value of 1 which is what I'm desiring.

However, when I use the Evaluate function in VBA a Type mismatch error
is thrown at me.

If Evaluate("=((A2:A2000=" & """" & "string" & """" & ")*(B2:B2000=" _
& """" & "string2" & """" & "))") Then

....

I can set the evaluate function to a variable, but only if its defined
as a variant and still I can't do anything with the results.

Help would be greatly appreciated. Thanks in advance.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Formula will not evaluate in VBA

On Jun 15, 4:30 pm, Dave Peterson wrote:
maybe just adding sum() to your expression???





" wrote:

I was wishing to test if duplicate names appeared within 2 columns and
take actions accordingly.


Here is the formula I was trying to evaluate.


=((A2:A2000="string")*(B2:B2000="string2"))


When I type the function in manually on an excel sheet I get a
value of 1 which is what I'm desiring.


However, when I use the Evaluate function in VBA a Type mismatch error
is thrown at me.


If Evaluate("=((A2:A2000=" & """" & "string" & """" & ")*(B2:B2000=" _
& """" & "string2" & """" & "))") Then


....


I can set the evaluate function to a variable, but only if its defined
as a variant and still I can't do anything with the results.


Help would be greatly appreciated. Thanks in advance.


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Wow, thanks Dave... that actually worked!

However are you aware of the explanation for why that is?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Formula will not evaluate in VBA

This expression:
=((A2:A2000="string")*(B2:B2000="string2"))
results in an array of 1999 0's and 1's.

Not especially useful until you do something else with it.

I bet if you look back at your notes (where you got that array formula), you'll
see either =sum() or =sumproduct() surrounding that worksheet formula.



" wrote:

On Jun 15, 4:30 pm, Dave Peterson wrote:
maybe just adding sum() to your expression???





" wrote:

I was wishing to test if duplicate names appeared within 2 columns and
take actions accordingly.


Here is the formula I was trying to evaluate.


=((A2:A2000="string")*(B2:B2000="string2"))


When I type the function in manually on an excel sheet I get a
value of 1 which is what I'm desiring.


However, when I use the Evaluate function in VBA a Type mismatch error
is thrown at me.


If Evaluate("=((A2:A2000=" & """" & "string" & """" & ")*(B2:B2000=" _
& """" & "string2" & """" & "))") Then


....


I can set the evaluate function to a variable, but only if its defined
as a variant and still I can't do anything with the results.


Help would be greatly appreciated. Thanks in advance.


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Wow, thanks Dave... that actually worked!

However are you aware of the explanation for why that is?


--

Dave Peterson
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
Might be a bug in Evaluate Formula? cyx Excel Discussion (Misc queries) 2 May 2nd 07 10:52 PM
cannot get concatenated formula to evaluate... green fox Excel Discussion (Misc queries) 2 April 25th 07 06:27 PM
What is evaluate formula? Rasoul Khoshravan Excel Worksheet Functions 11 October 27th 06 01:52 PM
Formula Will Not Evaluate Cecil Excel Worksheet Functions 3 April 25th 06 07:38 PM
Evaluate formula using VBA Ali Baba Excel Discussion (Misc queries) 0 August 17th 05 12:31 AM


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