1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| With Worksheets("Panier")
'On se place sur B9
Set oRng = .Range("B9")
'On parcours de B9 à la dernière ligne non-vide
For i = 0 To .Cells(.Rows.Count, 1).End(xlUp).Row - 1
'Si on trouve "Tablette" ou "Produits" (on peut enlever le LCase si souhaité)
'If LCase(oRng.Offset(i, 0)) = "Tablette" Or LCase(oRng.Offset(i, 0)) = "Produits" Then
If oRng.Offset(i, 0) = "Tablette" Or oRng.Offset(i, 0) = "Produits" Then
'On vérifie qu'on a des éléments à sa droite
If .Cells(oRng.Offset(i, 1).Row, .Columns.Count).End(xlToLeft).Column >= oRng.Offset(i, 1).Column Then
'Si oui, on récupère la range des valeurs
Set oProd = Range(oRng.Offset(i, 1), .Cells(oRng.Offset(i, 1).Row, .Columns.Count).End(xlToLeft))
'qu'on parcours.
For Each oCell In oProd
'Si on trouve quelque chose
If oCell <> "" Then
n = n + 1
'on sauvegarde les éléments.
ReDim Preserve oTable(1 To 2, 1 To n)
oTable(1, n) = oCell
oTable(2, n) = oCell.Offset(1, 0)
End If
Next oCell
End If
End If
Next i
End With |
Partager