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
| Sub Extract_Data()
Dim InpRng As Range, InpCl As Range
Dim ClValExtr As String, ClValAR As Variant
Dim RecPos As Integer
' A adapter sur la feuille et la cellule
Set InpRng = ThisWorkbook.Worksheets("Sheet1").Range("A1").CurrentRegion
RecPos = 9 'Record à extraire
' A adapter (Columns)
For Each InpCl In InpRng.Columns(1).Cells
Debug.Print InpCl.Value
'Je crée un tableau ClValAR contenant tous les enregistrements entre le " "
ClValAR = Split(InpCl.Value, " ")
' Si le nombre d'élèments retournés à supéreiur à l'extract que je recherche
If UBound(ClValAR, 1) >= RecPos Then
' Attention au type: ici on retourne un string
ClValExtr = ClValAR(RecPos)
InpCl.Offset(0, 1) = ClValExtr 'J'écris sur la colonne suivante
End If
Next InpCl
End Sub |
Partager