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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| Sub postraitement()
Dim ligne As Long, lig As Long, ligne_sh1 As Long
Dim chaine As String
ligne_sh1 = 1
With ActiveSheet
derlig = .Range("A65536").End(3).Row
For ligne = 1 To derlig Step 1
FirstCar = Left(Range("A" & ligne).Value, 1)
If FirstCar = "I" Or FirstCar = "M" Or FirstCar = "E" Then
'formattage de la ligne
chaine = Mid(Range("A" & ligne).Value, 1, 102)
'copier la 1ère ligne
Sheets("test").Cells(ligne_sh1, 1).Value = chaine
'récupérer les caractères 17 à 24 PMfield : Left(ligne
PMField = Mid(Range("A" & ligne).Value, 17, 8)
lig = 1
toto = InStr(1, Cells(ligne + lig, 1).Value, PMField)
'tant que ligne ++ ne contient pas PMfield (InStr),
While toto = 0
'formattage de la ligne
chaine = Mid(Cells(ligne + lig, 1).Value, 1, 102)
'copier la ligne en concaténant
Sheets("test").Cells(ligne_sh1, 1).Value = Sheets("test").Cells(ligne_sh1, 1).Value & chaine
lig = lig + 1
toto = InStr(1, PMField, Cells(ligne + lig, 1).Value)
lig = lig
Wend
ligne_sh1 = ligne_sh1 + 1
'sinon retourner au début du for
'else, ne rien faire
End If
Next ligne
End With
End Sub |
Partager