1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Sub TGB()
Dim LastLig As Long, i As Long
Dim Code As String
Dim j As Byte
Dim Deb, Fin, Inp, Oup() As String
'Les 2 tableaux doivent être trié par ordre croissant
Deb = Array("A", "APO", "B", "Z") 'Z en fin est nécessaire
Fin = Array("AOU", "AVR", "BEN", "ZZZ") 'ZZZ en fin est nécessaire
Application.ScreenUpdating = False
With Sheets("Feuil1")
LastLig = .Cells(.Rows.Count, "A").End(xlUp).Row
Inp = .Range("B2:B" & LastLig).Value
ReDim Oup(1 To LastLig - 1, 1 To 1)
For i = 1 To LastLig - 1
Code = Trim(UCase(Inp(i, 1)))
For j = 0 To UBound(Deb)
If StrComp(Code, Deb(j), 1) < 0 Then Exit For
Next j
Oup(i, 1) = "BLOC " & Deb(j - 1) & " à " & Fin(j - 1)
Next i
.Range("E2:E" & LastLig).Value = Oup
End With
End Sub |
Partager