Prendre une partie d'un chiffre

matrix

XLDnaute Occasionnel
Bonjour,

Petit problème.

Dans la colonne A, à partir de la ligne 5 en descendant, j'ai des chiffres composés ex: 67-20-5628562 0.

Je voudrais en VBA qu'il me remplace ses chiffres en gardant seulement la partie après le premier -

Comme dans l'exemple plus au, 67-20-5628562 0 deviendrait 20.

Je ne sais pas si ça ce fait!

Pouvez-vous m'aider s.v.p?

Merci
 

Pièces jointes

  • test3.zip
    6.6 KB · Affichages: 39
  • test3.zip
    6.6 KB · Affichages: 38
  • test3.zip
    6.6 KB · Affichages: 38
Dernière édition:

myDearFriend!

XLDnaute Barbatruc
Re : Prendre une partie d'un chiffre

Bonsoir Matrix, Stapple1600,

Une façon de faire :

A insérer dans l'évènement Click() de ton CommandButton :
Code:
[COLOR=GRAY][B][I]DANS LE MODULE DE CODE DE LA FEUILLE[/I][/B][/COLOR]

[COLOR=NAVY]Private Sub[/COLOR] CommandButton1_Click()
[COLOR=NAVY]Dim[/COLOR] L [COLOR=NAVY]As Long
    For[/COLOR] L = 2 [COLOR=NAVY]To[/COLOR] Cells(Application.Rows.Count, 1).[COLOR=NAVY]End[/COLOR](xlUp).Row
        Cells(L, 1).Value = Val(Mid(Cells(L, 1).Value, 4))
    [COLOR=NAVY]Next[/COLOR] L
[COLOR=NAVY]End Sub[/COLOR]
Cordialement,
 

Staple1600

XLDnaute Barbatruc
Re : Prendre une partie d'un chiffre

Re, bonsoir MyDearFriend


Une autre façon de faire

Code:
Sub extract_sur_feuille()
Dim s As String
Dim s1 As String
Dim i As Long
Dim pos1 as Long
For i = [A65536].End(xlUp).Row To 6 Step -1
s = Cells(i, 1).Text
s1 = Mid(s, InStr(1, s, "-") + 1)
pos1 = InStr(1, s1, "-")
Cells(i, 1) = Left(s1, pos1 - 1)
Next i
End Sub
 
Dernière édition:

Discussions similaires

Réponses
4
Affichages
410

Membres actuellement en ligne

Statistiques des forums

Discussions
313 344
Messages
2 097 337
Membres
106 916
dernier inscrit
Soltani mohamed