Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
iif() function
hi guys
hi Bob i have a following code dim t_string t_string= target.value target.clearcontents target.value=iif(isnumeric(t_string),cdbl(t_string )/100000,t_string) i am doing this to avoid circular reference but i am getting error "type mismatch" please help -- hemu -- hemu |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
iif() function
On Fri, 28 Sep 2007 20:21:00 -0700, Hemant_india
wrote: hi guys hi Bob i have a following code dim t_string t_string= target.value target.clearcontents target.value=iif(isnumeric(t_string),cdbl(t_strin g)/100000,t_string) i am doing this to avoid circular reference but i am getting error "type mismatch" please help -- hemu From HELP for IIF IIf always evaluates both truepart and falsepart, even though it returns only one of them. Because of this, you should watch for undesirable side effects. So you will get your error if t_string is not numeric, since truepart gets evaluated anyway. One way around this would be to use an IF statement. For example: If (IsNumeric(t_string)) Then target.value = CDbl(t_string) / 100000 Else target.value = t_string End If --ron |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
iif() function
thanks ron
-- hemu "Ron Rosenfeld" wrote: On Fri, 28 Sep 2007 20:21:00 -0700, Hemant_india wrote: hi guys hi Bob i have a following code dim t_string t_string= target.value target.clearcontents target.value=iif(isnumeric(t_string),cdbl(t_strin g)/100000,t_string) i am doing this to avoid circular reference but i am getting error "type mismatch" please help -- hemu From HELP for IIF IIf always evaluates both truepart and falsepart, even though it returns only one of them. Because of this, you should watch for undesirable side effects. So you will get your error if t_string is not numeric, since truepart gets evaluated anyway. One way around this would be to use an IF statement. For example: If (IsNumeric(t_string)) Then target.value = CDbl(t_string) / 100000 Else target.value = t_string End If --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) | Excel Worksheet Functions | |||
Excel - User Defined Function Error: This function takes no argume | Excel Programming | |||
Need to open the Function Arguments window from VBA for a user defined function. | Excel Programming | |||
Emulate Index/Match combo function w/ VBA custom function | Excel Worksheet Functions | |||
User-Defined Function pre-empting Built-in Function? How to undo???? | Excel Programming |