Je cherche la syntaxe pour sélectionner plusieurs cellules en ligne à partir de la cellule C2 et allant jusqu'à la case L.
Le nombre de cellule dépend d'une variable exemple: si ma variable = 2, sélectionner C2 et D2, si elle est égale à 3, sélectionner C2 D2 et E2 et ainsi de suite. J'ai essayé Set maplage = Range("C2" & ":L" & i) où i est égale à la valeur d'une cellule mais ça ne fonctionne pas :/
Dim iCol As Long
Dim cnt As Long, iCell As Long
With Range("C2:X2")
For iCol = .Columns.Count To 1 Step -1
For iCell = .Columns(iCol).Cells.Count To 1 Step -1
If .Cells(iCell, iCol).Interior.ColorIndex <> xlColorIndexNone Then
MsgBox .Cells(iCell, iCol).Address
Exit Sub
End If
Next
Next
End With
comment puis-je l'adapter pour avoir la cellule vide juste après ?
Dim iCol As Long
Dim cnt As Long, iCell As Long
With Range("C2:X2")
For iCol = .Columns.Count To 1 Step -1
For iCell = .Columns(iCol).Cells.Count To 1 Step -1
If .Cells(iCell, iCol).Interior.ColorIndex <> xlColorIndexNone Then
MsgBox .Cells(iCell, iCol + 1).Address
Exit Sub
End If
Next
Next
End With