chee seng ng
chee seng ng

Reputation: 131

Vba If else (Basic)

Would like to include a value to all my cells in column G if there are blank in column K, else no change.

If ActiveSheet.Range("K").Value, Criteria1:=" = " Then ActiveSheet.Range("G").Value = "Promo"

Else
    Exit Sub

Upvotes: 0

Views: 47

Answers (1)

rohrl77
rohrl77

Reputation: 3337

In order to test all the values you need to loop through the column. My example assumes the data doesn't have more than 100'000 lines and that you were testing for " = " to be included... addapt as needed.

Sub TestColumnK()

For i = 1 To ActiveSheet.Range("K100000").End(xlUp).Row
    If InStr(1, ActiveSheet.Range("K" & i).Value, "=") > 0 Then
        ActiveSheet.Range("G" & i).Value = "Promo"
    End If
Next i

End Sub

Upvotes: 1

Related Questions