1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Function Modif(ch As Range) As String
Dim NewCh As String
Dim NbPt As Long, PVg As Long, Pf As Long, i As Long
NewCh = ch
NbPt = Len(NewCh) - Len(Replace(NewCh, ".", ""))
Pos = 1
For i = 1 To NbPt / 2
Pt = InStr(Pos, NewCh, ".", 1) 'Position du point
PVg = InStr(Pos + 8, NewCh, ",", 1) 'Position de la virgule
PartieAConserver = Mid(NewCh, Pt, 6)
PartieASupprimer = Mid(NewCh, Len(PartieAConserver) + Pt, PVg - Len(PartieAConserver) - Pt)
NewCh = Replace(NewCh, PartieASupprimer, "")
Pt = InStr(Pt + 1, NewCh, ".", 1) 'Position du point
Pf = InStr(Pt + 1, NewCh, ")", 1) 'Position de la parenthèse fermante
PartieAConserver = Mid(NewCh, Pt, 6)
PartieASupprimer = Mid(NewCh, Len(PartieAConserver) + Pt, Pf - Len(PartieAConserver) - Pt)
NewCh = Replace(NewCh, PartieASupprimer, "")
Pf = InStr(Pt + 1, NewCh, ")", 1) 'Position de la parenthèse fermante
Pos = Pf + 1
Next i
Modif = NewCh
End Function |
Partager