View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Evaluate Custom Expression

The solution Tom gave you would create a string variable which could be
plugged straight into your SQL. Why would you need to parse that?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Peter" wrote in message
...
Thanks Tom, and is there any other automated way to do so?

Base on your solution, I still have to parse the string (from a TextBox),
locate " & __ & " characters and then change it to "Range()" property
manually.

Thanks,

"Tom Ogilvy" wrote:

Dim s as String

s = "CompanyName = 'ABC' AND DeptName = '" & Range("C1").Value _
& "' AND EmployeeName = '" & Range("NamedRange1").Value & "'"

--
Regards,
Tom Ogilvy

"Peter" wrote in message
...
Dears,

I'd like to create a TextBox and allow users to enter an expression,

for
instance,
CompanyName = 'ABC' AND DeptName = '" & C1 & "' AND EmployeeName = '"

&
NamedRange1 & "'"

This is a where clause like expression and I'd like to get the cell
reference / name range reference in my code. Is there any method that

I
can
use to evaluate an expression and obtain the actual values and then

concat
to
my SQL string? Or I have to use InStr or other indirect methods to

create
an
expression?

Thanks a lot!