View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Jackson Jim Jackson is offline
external usenet poster
 
Posts: 324
Default Type Mismatch error when number is negative

Did you try "If var1 <0 then"?

--
Best wishes,

Jim


"D.Farns" wrote:

Hello,

Need a little VBA help.

dim var1 as integer
var1 = countA - countB (for example)
If var1 0 then

This if statement works fine when var1 is a possitive number. When var1 is
a negative number I get a "Type Mismatch" error. Should I not be able to
compare a negative value with another number? I've tried declaring 0 as
integer variable to ensure both variables being compared in the If statement
are of the same type, but that didn't help. Any suggestions?

--
D.Farns