bonjour,
quel est le but de cette instruction ?
k = InStr(Numdoc(j), " ")
pour moi elle est inutile (pas de blanc dans cette colonne). Si elle est utile, alors il faut tester sa valeur pour une execution correcte de l'instruction suivante.
pWS.Cells(pRow, 2) = Left(Numdoc(j), k)
Ci dessous correction en supprimant ces instructions inutiles.
Sub Extraction()
Dim oWS As Worksheet, pWS As Worksheet
Dim oRow As Long, pRow As Long
Dim splitMultiLine As String, splitPerfix As String
Dim c As Long, i As Long, j As Long, k As Long
Dim Critère As Variant, Numdoc As Variant
Dim dataACol As String, dataBCol As String, dataCCol As String
Set oWS = Worksheets("Matrice")
Set pWS = Worksheets("Extraction")
'ligne titre
For c = 1 To 3
pWS.Cells(1, c) = oWS.Cells(1, c)
Next c
oRow = 2 ' ligne de oWS
pRow = 2 ' ligne de pWS
With oWS
While (.Cells(oRow, 1) <> "")
dataACol = .Cells(oRow, 1)
dataBCol = .Cells(oRow, 2)
dataCCol = .Cells(oRow, 3)
Critère = Split(dataACol, ",")
Numdoc = Split(dataBCol, Chr(10)) ' split (Char(10))
For i = LBound(Critère) To UBound(Critère)
For j = LBound(Numdoc) To UBound(Numdoc)
pWS.Cells(pRow, 1) = Trim(Critère(i)) ' critère colonne A
'k = InStr(Numdoc(j), " ")
'pWS.Cells(pRow, 2) = Left(Numdoc(j), k) ' n°doc colonne B
pWS.Cells(pRow, 2) = Numdoc(j) ' n°doc colonne B
pWS.Cells(pRow, 3) = dataCCol ' exigence conne C
pRow = pRow + 1
Next j
Next i
oRow = oRow + 1
Wend
End With
End Sub