A non-functioning If block

Solved
Iheb1975 Posted messages 40 Status Member -  
Iheb1975 Posted messages 40 Status Member -
Hello,

I am new to VBA and I have a problem with an If Block:
The code is as follows:

If My_type = "A" Then Type_Sinistre = "Automobile"
Else: Type_Sinistre = "Multirisque"
End If


When I run it, I get the following error message:
Compilation Error
Else without If


What is the problem exactly? Thank you in advance for your help

Configuration: Windows 7 / Firefox 44.0

1 answer

  1. michel_m Posted messages 18903 Registration date   Status Contributor Last intervention   3 320
     
    Hello,

    If My_type = "A" Then
    Type_Sinistre = "Automobile"
    Else
    Type_Sinistre = "Multirisque"
    End If

    When you put if ... Then... on the same line it closes the If, so your Else is expecting an If
    Michel
    0
    1. Iheb1975 Posted messages 40 Status Member
       
      Thank you.. it works
      0