ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Variant Array with String Values - Type Mismatch (https://www.excelbanter.com/excel-programming/293679-variant-array-string-values-type-mismatch.html)

jamiee

Variant Array with String Values - Type Mismatch
 
Hi

I'm sure there's a simple answer, but for the moment I'm stuck and I
have a deadline to meet. I have declared a three dimensional array as
being of variant type and then assigned various values to the array.
Some of the values assigned are numerical, some are strings.

Part of my code compares the values in the array. When comparing
values that contain numerical values there is no problem, yet when
comparing values that are strings I get the type mismatch error.

If one value was numerical and the other was a string I could
understand why this is, however I have checked that the two values are
both strings.

Anyone know what I'm doing wrong?

pikus

Variant Array with String Values - Type Mismatch
 
How are you comparing them

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Variant Array with String Values - Type Mismatch
 
if isnumeric(a) and isnumeric(b) then
if cdbl(a) = cdbl(b) then

else

end if
elseif vartype(a) = 8 and vartype(b) = 8 then
if a = b then

else

end if
else
' they don't match
end if

--
Regards,
Tom Ogilvy


"jamiee" wrote in message
om...
Hi

I'm sure there's a simple answer, but for the moment I'm stuck and I
have a deadline to meet. I have declared a three dimensional array as
being of variant type and then assigned various values to the array.
Some of the values assigned are numerical, some are strings.

Part of my code compares the values in the array. When comparing
values that contain numerical values there is no problem, yet when
comparing values that are strings I get the type mismatch error.

If one value was numerical and the other was a string I could
understand why this is, however I have checked that the two values are
both strings.

Anyone know what I'm doing wrong?





All times are GMT +1. The time now is 09:45 AM.

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