Bonsoir à tous,
Une proposition avec une fonction vba (voir classeur).
Option Explicit
Function Keep(x$, b As Boolean)
Dim i%, s$, n#
For i = 1 To Len(x)
Select Case Right(Left(x, i), 1)
Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
If b Then s = s & Right(Left(x, i), 1)
Case Else
If Not b Then s = s & Right(Left(x, i), 1)
End Select
Next i
If b Then
n = s
Keep = n
Else
Keep = Trim(s)
End If
End Function
Si il n'est pas important que les nombres extraits soient sous forme de texte (ce qui n'empèche pas le tri) on peut simplifier
Function KeepT$(x$, b As Boolean)
Dim i%, s$
For i = 1 To Len(x)
Select Case Right(Left(x, i), 1)
Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
If b Then s = s & Right(Left(x, i), 1)
Case Else
If Not b Then s = s & Right(Left(x, i), 1)
End Select
Next i
KeepT = Trim(s)
End Function
Cordialement
Jules