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 |
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 |
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 |
All times are GMT +1. The time now is 12:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com