Need help with Application.Evaluate

dryper

Board Regular
Joined
Nov 27, 2009
Messages
50
I have the following line in a function called GRADER, which keeps returning an error:

Code:
GRADER = Application.Evaluate("VLOOKUP(" & a.Address & ",{0,"U";0.5,5;0.6,4;0.65,3;0.7,2;0.75,1},2)")

It seems that the error is due to the quotes around the string "U". So is there any other way to embed a string within another string?

Thanks for viewing.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try this

Double the quotes

GRADER = Application.Evaluate("VLOOKUP(" & a.Address & ",{0,""U"";0.5,5;0.6,4;0.65,3;0.7,2;0.75,1},2)")

HTH

M.
 
Upvote 0
Strange how it is interpreted, but works nonetheless.. thanks!

You are welcome and tks for the feedback.

Comment:
Some people prefer to use Chr(34) instead of doubling the quotes

Code:
GRADER = Application.Evaluate("VLOOKUP(" & a.Address & ",{0," & _
    Chr(34) & "U" & Chr(34) & ";0.5,5;0.6,4;0.65,3;0.7,2;0.75,1},2)")

I dont like it - a matter of taste.

M.
 
Upvote 0
Strange how it is interpreted, but works nonetheless.. thanks!
VB uses quote marks to delineate text constants... anything between a set of quote marks are a text constant (that is, a collection of text characters). The problem with putting one or more single quote marks between the two quote marks delineating the text constant is that it confuses VB as to where the text constant begins and ends. So the programmers of VB devised a scheme to get around this problem... to include a single quote mark inside a text constant, you simply double up the quote marks... that is, wherever you want a single quote mark, just type two of them next to each other at that location.
 
Upvote 0
VB uses quote marks to delineate text constants... anything between a set of quote marks are a text constant (that is, a collection of text characters). The problem with putting one or more single quote marks between the two quote marks delineating the text constant is that it confuses VB as to where the text constant begins and ends. So the programmers of VB devised a scheme to get around this problem... to include a single quote mark inside a text constant, you simply double up the quote marks... that is, wherever you want a single quote mark, just type two of them next to each other at that location.

Rick,

Very good explanation.

M.
 
Upvote 0
I see this as string within a string. Just curious, is it possible to nest more levels of strings? So I guess it's more levels of quotes?

Also, what's the difference between single and double quotes?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,581
Messages
6,179,668
Members
452,936
Latest member
anamikabhargaw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top