mercredi 4 mars 2015

VBA if statement mismach error

I am trying to create a simple if statement. This if statement should move to the else statement when the value does not satisfy else if, but instead excel gives me a error 13 mismach error.


Here is my code:



Sub CALULATE()
Dim postage As String
Dim discountplaceholder As String

discount = Range("d10").Value

If discount = 0.1 Then

MsgBox "hello Bill"
discountplaceholder = 0.1

ElseIf discount = 0.05 Then

MsgBox "hello BOB"
discountplaceholder = 0.05

Else
MsgBox "hello dan"
discountplaceholder = 0

End If
End Sub


The third cell value (the one it is if it isn't 0.1 or 0.05) is "NOT APPLICABLE FOR DISCOUNT". Does anyone know how I can solve this?


Thanks in advance.


Aucun commentaire:

Enregistrer un commentaire