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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
Private Sub CommandButton1_Click()
Dim Pos As Integer
Dim Voyel As String
Dim objRange As Range
Dim cel As Range
'défini la plage de cellules
Set objRange = Range("C1").EntireColumn.SpecialCells(xlCellTypeConstants)
'parcour la plage
For Each cel In objRange
'effectue la recherche
Pos = InStr(cel, "inb ")
'si trouvé
If Pos <> 0 Then
Voyel = Voyel & Mid(cel, Pos, 7)
cel.Offset(0, -2).Value = Right(Voyel, 3)
cel.Offset(0, -1).Value = Application.WorksheetFunction.VLookup(Val(Right(Voyel, 3)), Sheets("REF").Range("$A$1:$B$95"), 2, False)
GoTo FinCel 'va à la fin de la boucle
End If
Pos = InStr(cel, "eva/")
If Pos <> 0 Then
Voyel = Voyel & Mid(objRange, Pos, 6)
cel.Offset(0, -2).Value = Right(Voyel, 2)
cel.Offset(0, -1).Value = Application.WorksheetFunction.VLookup(Val(Right(Voyel, 2)), Sheets("REF").Range("$I$2:$J$9"), 2, False)
GoTo FinCel 'va à la fin de la boucle
End If
Pos = InStr(cel, "udd/")
If Pos <> 0 Then
Voyel = Voyel & Mid(cel, Pos, 6)
cel.Offset(0, -2).Value = Right(Voyel, 2)
cel.Offset(0, -1).Value = Application.WorksheetFunction.VLookup(Val(Right(Voyel, 2)), Sheets("REF").Range("$G$2:$H$10"), 2, False)
GoTo FinCel 'va à la fin de la boucle
End If
Pos = InStr(cel, "cea/")
If Pos <> 0 Then
Voyel = Voyel & Mid(cel, Pos, 6)
cel.Offset(0, -2).Value = Right(Voyel, 2)
cel.Offset(0, -1).Value = Application.WorksheetFunction.VLookup(Val(Right(Voyel, 2)), Sheets("REF").Range("$K$2:$L$7"), 2, False)
GoTo FinCel 'va à la fin de la boucle
End If
Pos = InStr(cel, "dra/")
If Pos <> 0 Then
Voyel = Voyel & Mid(cel, Pos, 6)
cel.Offset(0, -2).Value = Right(Voyel, 2)
cel.Offset(0, -1).Value = Application.WorksheetFunction.VLookup(Val(Right(Voyel, 2)), Sheets("REF").Range("$M$2:$N$6"), 2, False)
GoTo FinCel 'va à la fin de la boucle
End If
Pos = InStr(cel, "nts/")
If Pos <> 0 Then
Voyel = Voyel & Mid(cel, Pos, 6)
cel.Offset(0, -2).Value = Right(Voyel, 2)
cel.Offset(0, -1).Value = Application.WorksheetFunction.VLookup(Val(Right(Voyel, 2)), Sheets("REF").Range("$O$2:$P$15"), 2, False)
'GoTo FinCel ici pas nécessaire !
End If
FinCel:
Next cel
End Sub |
Partager