Type Mismatch Error

elotromateo

New Member
Joined
May 19, 2010
Messages
42
I have an interesting type mismatch error. I am using a UDF that needs inputs that are type Double. The inputs I am using are parts of arrays that have been defined as Variant. When I try converting the center part which is a subtraction of two arrays, the error occurs. If I get rid of the subtraction, the code works, but I need the subtraction and do not want to clutter up space by writing the code for another array that is so simple to write here. I have also tried converting them separately, but that does not work either. Does anyone know how to fix this?


Code:
Works:
ElseIf OAWeather(i, 1) > embedpsych("EN", "DB", [COLOR="red"]CDbl(DATSP(i, 1))[/COLOR], "HR", CDbl(DAHR(i, 1))) Then

Doesn't work:
ElseIf OAWeather(i, 1) > embedpsych("EN", "DB", [COLOR="Red"]CDbl(DATSP(i, 1) - SFHeat(i, 1))[/COLOR], "HR", CDbl(DAHR(i, 1))) Then
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Ah, figured it out. I incorrectly assumed that the UDF gave an output as Double (it was Variant). All it took was a CDbl around the UDF and it worked just fine.
 
Upvote 0

Forum statistics

Threads
1,224,559
Messages
6,179,515
Members
452,921
Latest member
BBQKING

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top