vendredi 14 juin 2019

VBA Table For Each If Then Loop - text repeat

I need a code that looks through a column in a table and if the text there is a certain string, then new text needs to be entered in another column.

So, review column A (Service Sub Type), enter text in column B (Product Category) based on column A. This is what I have so far.

Dim productsubtype As Range

For Each productsubtype In Range("RawData[Service Sub Type]")
    If productsubtype.Value = "Training" Then
    Range("RawData[Product Category]").Value = "Education"

    End If

Next productsubtype

But what's happening is that it is just populating all of column B with "Education", regardless of what is in column A. What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire