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
| Sub Comptabilisation()
Dim Ligne As Long
Dim Colonne As Long
Dim Position As Long
With ThisWorkbook.Worksheets("Feuil1")
' dernière ligne
Ligne = .Cells(Rows.Count, 1).End(xlUp).Row
' dernière colonne
Colonne = .Cells(1, Columns.Count).End(xlToLeft).Column
' parcours les lignes
For Ligne = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
' parcours les colonnes
For Colonne = 1 To .Cells(1, Columns.Count).End(xlToLeft).Column
' cherche le DKxxx dans la ligne
If .Cells(Ligne, 1) Like "*" & .Cells(1, Colonne) & "*" Then
'position de la fin du DLKxxx dans la ligne
Position = InStr(1, .Cells(Ligne, 1), .Cells(1, Colonne)) + 3
' écriture du résultat, en identifiant la virgule dans le chiffre
.Cells(Ligne, Colonne) = CDbl(Mid(.Cells(Ligne, 1), Position + 3, InStr(Position, .Cells(Ligne, 1), ",") - Position))
End If
Next Colonne
Next Ligne
End With
End Sub |
Partager