mercredi 1 juin 2016

If then Else Excel VBA - "End If" needed?

so I m writing a UDF in Excel vba of the kind:

function ... if ... then ... else for i... to ... equations ... next i * end function

Now I noticed, that the function seems to work just fine, however I was wondering whether I shouldnt be using an "end if" at the position of (*) in the code? If I do, I receive an error msg stating there was no if corresponding IF to that "end if" block, though!? So in general, isn't there a Need for an "end if" in if then else constructions ? Thanks in advance!

/edit: 'if ... then ... else' is a one liner. However the else block does contain multiple lines and in particular a loop...

Aucun commentaire:

Enregistrer un commentaire