I have an if statment checking for equality of a variable cast as a double. It checks if the variable contains anything at all and if the number is greater is 0.
However, when I check to see if the variable (num1) = 0 or num1 = "", I get a Type Mismatch Error.
num1 is a number take from a worksheet as a double:
num1 = loc.Cells(6, 5).Value
This currently assigns the value of 7800 to num1: num1 = 7800
However the code errors on the ElseIf statement stating there is a Type Mismatch:
ElseIf num1 = 0 Or num1 = "" Then
GoTo nocurrentnumber
If Not makenumber Then
makenumber = NumberMaker(startdate, enddate)
Set numbersheet = ThisWorkbook.Worksheets("Current Number")
Else
If PnL_Sheet.Cells(Startrow, i).Value > StartDate And PnL_Sheet.Cells(Startrow, i).Value <= EndDate Then
PnL_Sheet.Cells(Startrow, numberLine).Value = number
Else
End If
End If
nocurrentnumber:
Else
PnL_Sheet.Cells(Startrow, numberLine).Value = 0
Shouldn't the variables set to double be able to check for these types of equality? Or am I missing something else?
I have read the following posts, each of which provide an answer I don't think I can use:
Excel VBA Run-time error '13': Type mismatch
""
? Double is numeric only if I recall correctly – Andreas