vendredi 23 octobre 2015

VBA If elseif and list of conditions

I have a code for looping through all cells in a range, but I have just found out that the second condition below (cell.row()<>1) should actually be changed into something like cell.row<>1,2,3,4,5 - so a list of exclusions. Is there a quick way of changing this, easier that changing the whole If-Elseif into a Select Case statement?

For Each cell In MyTable
    If cell.Row() = TableFirstRow And cell.Column() = TableFirstColumn Then
        'do stuff
    ElseIf cell.Row() <> 1 And cell.Column() = TableFirstColumn Then
        'do some other stuff
    Elseif...
    End If
Next cell

Aucun commentaire:

Enregistrer un commentaire