ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Evaluate function (https://www.excelbanter.com/excel-programming/422436-evaluate-function.html)

avi

Evaluate function
 
Hello,

In an Evaluate statement I use a variable (MyVar) im the middle of the
function, something like

ddd= Evaluate("expression 1" & MyVar & "expression 2")

When MyVar is not numeric I use

ddd= Evaluate("expression 1" & Chr(34) & MyVar & Chr(34) &
"expression 2")

I look for a way to use one Evaluate statement only , both for numeric
and non numeric ddd instead of 2 statements with IF


Thanks a lot
Avi

JE McGimpsey

Evaluate function
 
One way:

ddd = Evaluate("expression 1" & _
Iif(IsNumeric(MyVar),MyVar, Chr(34) & MyVar & Chr(34)) & _
"expression 2")

In article
,
avi wrote:

Hello,

In an Evaluate statement I use a variable (MyVar) im the middle of the
function, something like

ddd= Evaluate("expression 1" & MyVar & "expression 2")

When MyVar is not numeric I use

ddd= Evaluate("expression 1" & Chr(34) & MyVar & Chr(34) &
"expression 2")

I look for a way to use one Evaluate statement only , both for numeric
and non numeric ddd instead of 2 statements with IF


Thanks a lot
Avi



All times are GMT +1. The time now is 12:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com