Sub pack()
Columns('C:C').Select
Selection.Insert Shift:=xlToRight
Selection.NumberFormat = 'General'
Range('C1').Select
ActiveCell.FormulaR1C1 = 'Qté par pack'
Dim Tbl() As String, DerK As Integer, K As Integer
DerK = Sheets('Prix augmenté').Range('A3').End(xlDown).Row
ReDim Tbl(1 To DerK, 1 To 2) 'dimensionne à x lignes,2 colonne
'Rempli
For K = 3 To DerK
Tbl(K, 1) = Sheets('Prix augmenté').Range('E' & K)
Next K
'Fin Rempli
'Remplace
For K = 1 To DerK
If InStr(Tbl(K, 1), 'PAGEPACK') <> 0 Then
Tbl(K, 1) = 1
Else:
If InStr(Tbl(K, 1), 'PAGE PACK') <> 0 Then
Tbl(K, 1) = 1
Else:
'1) CARTON DE:
'a) cartons de :
If InStr(Tbl(K, 1), 'CARTONS DE') <> 0 Then
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTONS DE') - 9), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTONS DE') - 10)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTONS DE') - 9)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'b) carton__de
If InStr(Tbl(K, 1), 'CARTON DE') <> 0 Then
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTON DE') - 9), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTON DE') - 10)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTON DE') - 9)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'c) cartonde
If InStr(Tbl(K, 1), 'CARTONDE') <> 0 Then
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTONDE') - 7), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTONDE') - 8)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTONDE') - 7)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'd) cartonsde
If InStr(Tbl(K, 1), 'CARTONSDE') <> 0 Then
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTONSDE') - 8), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTONSDE') - 9)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTONSDE') - 8)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'e) carton de
If InStr(Tbl(K, 1), 'CARTON DE') <> 0 Then
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTON DE') - 8), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTON DE') - 9)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'CARTON DE') - 8)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'2)PACK DE
'a)packs de
If InStr(Tbl(K, 1), 'PACKS DE') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PACK DE')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACKS DE') - 7), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACKS DE') - 8)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACKS DE') - 7)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'b)pack__de
If InStr(Tbl(K, 1), 'PACK DE') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PACK DE')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACK DE') - 7), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACK DE') - 8)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACK DE') - 7)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'c)packde
If InStr(Tbl(K, 1), 'PACKDE') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PACK DE')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACKDE') - 5), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACKDE') - 6)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACKDE') - 5)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'd)packsde
If InStr(Tbl(K, 1), 'PACKSDE') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PACKSDE')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACKSDE') - 6), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACKSDE') - 7)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACKSDE') - 6)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'e)pack de
If InStr(Tbl(K, 1), 'PACK DE') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PACK DE')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACK DE') - 6), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACK DE') - 7)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACK DE') - 6)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'3)PK DE
'a) pks de
If InStr(Tbl(K, 1), 'PKS DE') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PK DE')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PKS DE') - 5), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PKS DE') - 4)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PKS DE') - 5)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'b)pk__de
If InStr(Tbl(K, 1), 'PK DE') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PK DE')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PK DE') - 5), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PK DE') - 6)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PK DE') - 5)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'c)pkde
If InStr(Tbl(K, 1), 'PKDE') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PK DE')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PKDE') - 3), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PKDE') - 4)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PKDE') - 3)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'd)pksde
If InStr(Tbl(K, 1), 'PKSDE') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PK DE')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PKSDE') - 4), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PKSDE') - 5)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PKSDE') - 4)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'e)pk de
If InStr(Tbl(K, 1), 'PK DE') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PK DE')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PK DE') - 4), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PK DE') - 5)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PK DE') - 4)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'4)PACK
'a)packs
If InStr(Tbl(K, 1), 'PACKS') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PACK')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACKS') - 5), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACKS') - 4)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACKS') - 3)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'b) pack
If InStr(Tbl(K, 1), 'PACK') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PACK')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACK') - 3), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACK') - 4)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PACK') - 3)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'5)PK
'a)pks
If InStr(Tbl(K, 1), 'PKS') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PK')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PKS') - 2), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PKS') - 1)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PKS') - 2)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
'b)pk
If InStr(Tbl(K, 1), 'PK') <> 0 Then
'Tbl(K, 2) = InStr(Tbl(K, 1), 'PK')
If Left(Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PK') - 1), 1) = ' ' Then
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PK') - 2)
Else:
Tbl(K, 1) = Right(Tbl(K, 1), Len(Tbl(K, 1)) - InStr(Tbl(K, 1), 'PK') - 1)
End If
If IsNumeric(Right(Left(Tbl(K, 1), 2), 1)) Then
Tbl(K, 1) = Left(Tbl(K, 1), 2)
Else:
Tbl(K, 1) = Left(Tbl(K, 1), 1)
End If
Tbl(K, 2) = IsNumeric(Tbl(K, 1))
Else:
If InStr(Tbl(K, 1), 'CARTON DE') = 0 And InStr(Tbl(K, 1), 'PACK DE') = 0 _
And InStr(Tbl(K, 1), 'PK DE') = 0 And InStr(Tbl(K, 1), 'PACK') = 0 And _
InStr(Tbl(K, 1), 'PK') = 0 Then
Tbl(K, 1) = 1
'Tbl(K, 2) = 'Rien trouvé'
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Next K
'Fin Remplace
'Affiche
For K = 3 To UBound(Tbl)
Sheets('Prix augmenté').Range('C' & K).Value = Tbl(K, 1)
Next K
'Fin Affiche
''Affiche
'For K = 3 To UBound(Tbl)
'Sheets('Prix augmenté').Range('B' & K).Value = Tbl(K, 2)
'Next K
''Fin Affiche
End Sub