mercredi 20 novembre 2019

VBA: Use IF statement to psuh Next statement if true

I am trying to look at ways to if a statement is true, go to next for statement instead of carrying on code. The issue is kicking off on If comment_Or_coupon Then goto Next rowHeader, because I cant go to the next rowHeader.

Sub UniqueFetchDBTabletest()
    Dim tempList As Variant
    Dim rowHeader As Variant
    Dim comment_Or_coupon As Boolean

    tempList = [RangeofIDCells]
    For Each rowHeader In tempList:
        comment_Or_coupon = False
        If InStr(1, LCase(rowHeader), "comment", vbTextCompare) = 0 Then comment_Or_coupon = True
        If InStr(1, LCase(rowHeader), "coupon", vbTextCompare) = 0 Then comment_Or_coupon = True
        If comment_Or_coupon Then goto Next rowHeader

        ' else i want to continue doing code

    Next rowHeader
End Sub


Aucun commentaire:

Enregistrer un commentaire