mercredi 18 juillet 2018

vba if cells do not equal values then delete

I'm fairly new to VBA and I can't seem to figure this one out through google.

I'm trying to run through a worksheet and use an If statement to delete unnecessary columns, based on their row 1 values. I'm trying to do it like this:

    Sub Macro1
    Dim cell As Range
    For Each cell In Rows("1")
    If cell.Value <>  "order_number", "tax_details", "etc"
    Then .EntireColumn.delete
    End Sub

But I can't seem to figure out how to use the "If cell.Value" statement with multiple values, nor how to delete the columns that I don't want. Any help is much appreciated.

Cheers,

Justin

Aucun commentaire:

Enregistrer un commentaire