Solved

# Evaluate Function and Chr(34) in excel vba

Posted on 2007-03-20
746 Views
This statement below is true, but it is not recognizing it as true. I assume it is because I need to put the Chr(34) somewhere but I do not know where I need to. Can you help me?

If Application.Evaluate(Chr(34) & InStr(r.Offset(0, VarA1).Value, VarC1) > 0 & Chr(34)) Then run code a

0
Question by:tiehaze
• 2
• 2

LVL 80

Accepted Solution

byundt earned 500 total points
ID: 18757894
Why are you using Evaluate at all? Why not:
If InStr(1, r.Offset(0, VarA1).Value, VarC1) > 0 Then 'run code a
0

Author Comment

ID: 18757931
the code I am using is very complicated, I just threw in that one line

The reason I am using evaluate is because I have a variable that is equal to:
=
<>
>
<
and the only way to use those is with evaluate.
0

Author Comment

ID: 18757939
nevermind, you are correct. thanks
0

LVL 80

Expert Comment

ID: 18757958
If you have an operator, as in your earlier question, you do not need the Chr(34) at all. This is because you are concatenating several values, and the result is a string. Putting that string inside double quotes then causes an error because the double quotes aren't required.
0

LVL 85

Expert Comment

ID: 18757967
FYI, you only needed the CHR(34) before because you were comparing text strings ("M"="M" is true, but M=M makes Excel think M is a variable of some kind). Here you are are comparing numbers, so you wouldn't need the CHR(34).
Regards,
Rory
0

## Featured Post

Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.