mardi 10 juillet 2018

VBA - IF Statement not

Below is my VBA Code that will label a Company Name if its "Climate", "ComRes" or "Remnants"

For i = startrow To lastrow
    Company = dbsheet.Range("E" & i).Value
    Office = dbsheet.Range("G" & i).Value

    If InStr(Company, "Climate") Or (Company = "CT") Or (Company = "DSN") Or (Company = "WR") Then
    Label = "Climate"

    ElseIf (Company = "ECRS") And (Office = "(Platform Level)" Or Office = "CM" Or Office = "CM Grantsville") Then
    Label = "ComRes"

    Else
    Label = "Remnants"


    dbsheet.Range("H" & i).Value = Label
    End If

My Main Issue is that if the company name falls under "Climate" or "ComRes", it does not give any label. Just Null. But it is working for "Remnants"

Here are the results

Is there something wrong with if else part? Thanks!

Aucun commentaire:

Enregistrer un commentaire