Dazzybee
Dazzybee

Reputation: 1

Excel VBA If this is true End otherwise do this

How would I write a VBA statement that basically says if "A1" says "Yes" ignore the rest of the my code and End otherwise go to the next line.

Thanks

I cant seem to get it to work, i cant get it to skip the rest of the code

Upvotes: 0

Views: 53

Answers (1)

martinitram
martinitram

Reputation: 31

Easy... ;-)

enter image description here

Sub YesICan()

    Dim rng As Range
    Set rng = Selection
    Dim cl As Range

    For Each cl In rng.Cells
        If LCase(cl) = "yes" Then
            cl.Offset(, 1) = "Hi There!"
        Else
            cl.Offset(, 1) = ""
            'do other stuff
        End If
    Next cl


End Sub

Upvotes: 0

Related Questions