Thema Datum  Von Nutzer Rating
Antwort
26.11.2020 18:02:18 brezi
Solved
26.11.2020 18:04:57 Gast90639
NotSolved
27.11.2020 10:32:15 volti
Solved
27.11.2020 10:39:13 volti
NotSolved
27.11.2020 11:01:37 brezi
Solved
27.11.2020 11:54:33 volti
NotSolved
27.11.2020 16:44:57 brezi
Solved
27.11.2020 17:52:30 volti
NotSolved
27.11.2020 19:56:12 volti
Solved
30.11.2020 11:48:07 brezi
NotSolved
30.11.2020 12:03:01 volti
Solved
30.11.2020 12:13:41 brezi
NotSolved
Rot UserForm Array into BubbleSort
30.11.2020 13:00:38 volti
Solved
30.11.2020 14:08:49 brezi
Solved
30.11.2020 14:10:50 volti
NotSolved
27.11.2020 11:09:13 RPP63
NotSolved
27.11.2020 11:13:50 brezi
NotSolved

Ansicht des Beitrags:
Von:
volti
Datum:
30.11.2020 13:00:38
Views:
527
Rating: Antwort:
 Nein
Thema:
UserForm Array into BubbleSort

Hallo Brezi,

so sollte es jetzt funktionieren.

Habe das jetzt nachgebaut. Ist immer blöd, wenn man nicht testen kann.

Private Sub UserForm_Initialize()
 Dim oCol As New Collection
 Dim Obj As Range
 Dim i As Integer
 
 TextBox1.Value = "TT.MM.JJJJ"
 TextBox2.Value = "TT.MM.JJJJ"
  
'Daten sortiert in Collection einfügen
 For Each Obj In ThisWorkbook.Worksheets("Vergabe nach VE").Range("E7:E400")
     CollectionAddItem oCol, Obj.Value  'Wert in Collection
 Next Obj
 ComboBox1.Clear
 For i = 1 To oCol.Count
     ComboBox1.AddItem oCol.Item(i)     'Collection in Combobox
 Next i

End Sub

Function CollectionAddItem(oCol As Collection, ByVal sItem As String, Optional iPos As Integer, Optional ByVal vKey As Variant) As Long
'Funktion fügt einen Eintrag sortiert in eine Collectionsammlung ein, Einträge können nicht mehrfach vorkommen
  Dim nStart As Long, nEnd As Long, nX As Long
     
  If Trim$(sItem) = "" Then Exit Function
  With oCol
    If iPos <> 0 Then
       .Add sItem, vKey, iPos
    ElseIf .Count < 1 Then
       .Add sItem, vKey                     'wenn Collection noch leer ist
'Neuen Eintrag mit 1. Eintrag vergleichen
    ElseIf .Item(1) > sItem Then
       .Add sItem, vKey, 1                  'an 1. Position einfügen
    ElseIf .Item(1) Like sItem _
        Or .Item(.Count) Like sItem Then
'jetzt mit letzten Eintrag vergleichen
    ElseIf .Item(.Count) < sItem Then
        .Add sItem, vKey                    'an letzter Position einfügen
    Else
'durch binäre Suche die korrekte Position ermitteln
        nStart = 1: nEnd = .Count
        Do
          nX = (nStart + nEnd) \ 2
          If nX = nStart Then Exit Do
'Vergleich
          If .Item(nX) = sItem Then Exit Function
          If .Item(nX) > sItem Then nEnd = nX
          If .Item(nX) < sItem Then nStart = nX
        Loop
        On Error Resume Next
        .Add sItem, vKey, , nX
    End If
  End With
End Function

viele Grüße

Karl-Heinz


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
26.11.2020 18:02:18 brezi
Solved
26.11.2020 18:04:57 Gast90639
NotSolved
27.11.2020 10:32:15 volti
Solved
27.11.2020 10:39:13 volti
NotSolved
27.11.2020 11:01:37 brezi
Solved
27.11.2020 11:54:33 volti
NotSolved
27.11.2020 16:44:57 brezi
Solved
27.11.2020 17:52:30 volti
NotSolved
27.11.2020 19:56:12 volti
Solved
30.11.2020 11:48:07 brezi
NotSolved
30.11.2020 12:03:01 volti
Solved
30.11.2020 12:13:41 brezi
NotSolved
Rot UserForm Array into BubbleSort
30.11.2020 13:00:38 volti
Solved
30.11.2020 14:08:49 brezi
Solved
30.11.2020 14:10:50 volti
NotSolved
27.11.2020 11:09:13 RPP63
NotSolved
27.11.2020 11:13:50 brezi
NotSolved