Excel alle Versionsnummern eines Teils in einer Zeile aufzählen

Man kann zu Beginn der Funktion alles erstma sortieren, dann hat man das Problemm gleich eliminiert.
Es gibt schon eingebaute Routinen in VBA dafür.

z.B. so

Code:
Sub AbgerundetesRechteck1_Klicken()
'Sortieren'
    With ThisWorkbook.Sheets.Item(1).Sort
        .SortFields.Clear
        .SortFields.Add Key:=Range("A1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortTextAsNumbers
        .SetRange Range("A2:D" & Sheets(1).UsedRange.SpecialCells(xlCellTypeLastCell).Row)
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

Dim db As MakeItADatabase
Dim strResult As String
Dim intRowsOnSemicolon As Integer
Set db = New MakeItADatabase
 
Dim x As Long 'row counter
x = 1 'ignore header
 
db.SetSheet = ThisWorkbook.Sheets.Item(1)
With ThisWorkbook.Sheets.Item(1)
    Do
        x = x + 1
        If .Cells(x, 1) = "" Then Exit Sub
        strResult = db.GetAllVersions(.Cells(x, 1), .Cells(x, 2))
        intRowsOnSemicolon = UBound(Split(strResult, ";"))
        
        .Range("D" & x & ":D" & x + intRowsOnSemicolon) = Left(strResult, Len(strResult) - 2)
        x = x + intRowsOnSemicolon
        strResult = ""
    Loop Until x = 0
End With

Set db = Nothing
End Sub
 
Zuletzt bearbeitet:
Zurück
Oben