Copiez dans différentes colonnes ce qui est pair et impair séparant par ":"

J'ai le code suivant: A106: A107: A110: A111: A112: A113: A118: A119

J'aimerais get une réponse dans deux colonnes différentes: pair et impair .

Exemple: A106: A110: A112: A118 et A107: A111: A113: A119 .

Quelqu'un pourrait-il me donner une idée de ce qu'il faut faire automatiquement?

Essayez cette fonction VBA:

 Public Function ExtractOdds(Data As Ssortingng, Delimiter As Ssortingng, IsOdd As Boolean) As Ssortingng Dim Elements() As Ssortingng Dim Result As Ssortingng Elements = Split(Data, Delimiter) For Each Item In Elements If Right(Item, 1) Mod 2 = -IsOdd Then If Len(Result) > 0 Then Result = Result & Delimiter End If Result = Result & Item End If Next Item ExtractOdds = Result End Function 

Utilisation pour extraire des valeurs impaires

 =ExtractOdds(A1,":",TRUE) 

Utilisation pour extraire des valeurs égales:

 =ExtractOdds(A1,":",FALSE) 

Cela le ferait:

 Sub Test() Dim sPart, sFull As Ssortingng Dim WS1, WS2 As Worksheet Dim i As Long Set WS1 = ActiveSheet sFull = "A106:A107:A110:A111:A112:A113:A118:A119" Sheets.Add After:=Sheets(Sheets.Count) Set WS2 = ActiveSheet WS2.Range("A1").Value = "Odd" WS2.Range("B1").Value = "Even" Do While InStr(sFull, ":") sPart = Left(sFull, InStr(sFull, ":")) i = Mid(sPart, 2, Len(sPart) - 2) If i Mod 2 <> 0 Then WS2.Range("A" & WS2.Rows.Count).End(xlUp).Offset(1).Value = Left(sPart, Len(sPart) - 1) Else WS2.Range("B" & WS2.Rows.Count).End(xlUp).Offset(1).Value = Left(sPart, Len(sPart) - 1) End If sFull = Right(sFull, Len(sFull) - Len(sPart)) Loop sPart = sFull i = Mid(sPart, 2, Len(sPart) - 1) If i Mod 2 <> 0 Then WS2.Range("A" & WS2.Rows.Count).End(xlUp).Offset(1).Value = Left(sPart, Len(sPart) - 1) Else WS2.Range("B" & WS2.Rows.Count).End(xlUp).Offset(1).Value = Left(sPart, Len(sPart) - 1) End If End Sub