Gruppe
Allgemein
Problem
Die Namen aus Spalte A sollen so sortiert werden, dass bei der Ausgabe die Namen WERNER, DANIELA, ANGELA, JOACHIM, ROSI, HARALD immer am Anfang stehen.
StandardModule: basMain
Sub TeilSort()
Dim arrFirst(1 To 6) As String
Dim arrSecond() As String
Dim arrTmp As Variant
Dim varTest As Variant
Dim iRow As Integer, iCounter As Integer
Columns("B").ClearContents
arrFirst(1) = "WERNER"
arrFirst(2) = "DANIELA"
arrFirst(3) = "ANGELA"
arrFirst(4) = "JOACHIM"
arrFirst(5) = "ROSI"
arrFirst(6) = "HARALD"
iRow = 1
Do Until IsEmpty(Cells(iRow, 1))
varTest = Application.Match(Cells(iRow, 1).Value, arrFirst, 0)
If IsError(varTest) Then
iCounter = iCounter + 1
ReDim Preserve arrSecond(1 To iCounter)
arrSecond(iCounter) = Cells(iRow, 1).Value
End If
iRow = iRow + 1
Loop
arrTmp = QuickSort(arrSecond)
For iRow = 1 To 6
Cells(iRow, 2).Value = arrFirst(iRow)
Next iRow
For iCounter = iRow To UBound(arrTmp) + iRow - 1
Cells(iCounter, 2).Value = arrTmp(iCounter - iRow + 1)
Next iCounter
End Sub