11.10.2013 Aufrufe

Excel aufmöbeln mit VBA

Excel aufmöbeln mit VBA

Excel aufmöbeln mit VBA

MEHR ANZEIGEN
WENIGER ANZEIGEN

Erfolgreiche ePaper selbst erstellen

Machen Sie aus Ihren PDF Publikationen ein blätterbares Flipbook mit unserer einzigartigen Google optimierten e-Paper Software.

Auf Boolean Auf True <br />

<br />

’ Quelle:<br />

’ http://dbwiki.net/wiki/<strong>VBA</strong>_Tipp:_Bubblesort (31.1.2013)<br />

’ Ganz leicht verändert<br />

Public Function BubbleSortAsc(vArray As Variant) As Long<br />

’<br />

’ Ascending: aufsteigend sortieren<br />

’<br />

If Not IsArray(vArray) Then Exit Function<br />

Dim Mark As Long, i As Long<br />

Dim EndIdx As Long, StartIdx As Long<br />

Dim Temp As Variant<br />

Dim cnt As Long<br />

cnt = 0<br />

EndIdx = UBound(vArray)<br />

StartIdx = LBound(vArray)<br />

Do While EndIdx > StartIdx<br />

Mark = StartIdx<br />

For i = StartIdx To EndIdx - 1<br />

Marke: If vArray(i) > vArray(i + 1) Then<br />

Temp = vArray(i)<br />

vArray(i) = vArray(i + 1)<br />

vArray(i + 1) = Temp<br />

Mark = i<br />

cnt = cnt + 1<br />

End If<br />

Next i<br />

EndIdx = Mark<br />

Loop<br />

BubbleSortAsc = cnt<br />

End Function<br />

’ Genauso Absteigend sortieren: In der markierten Anweisung<br />

’ das Vorzeichen > durch < ersetzen<br />

Public Function BubbleSortAsc(vArray As Variant) As Long<br />

usw.<br />

Function BubbleSort(ByRef vArray As Variant, _<br />

ByVal Asc As Boolean)<br />

If Asc Then<br />

BubbleSort = BubbleSortAsc(vArray)<br />

Else

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!