AW: Sortierung in einer ListBox
25.07.2010 20:57:24
Josef
Hallo Sebastian,
bei gebundenen Listboxen muss man den Zellinhalt verschieben.
' **********************************************************************
' Modul: Tabelle1 Typ: Element der Mappe(Sheet, Workbook, ...)
' **********************************************************************
Option Explicit
Private Sub CommandButton1_Click()
Dim strTmp As String, rng As Range, lngI As Long
With ListBox1
Set rng = Range(.ListFillRange)
lngI = .ListIndex
If lngI > 0 Then
strTmp = .List(lngI - 1)
rng.Cells(lngI, 1) = .List(lngI)
rng.Cells(lngI + 1, 1) = strTmp
End If
End With
End Sub
Private Sub CommandButton2_Click()
Dim strTmp As String, rng As Range, lngI As Long
With ListBox1
Set rng = Range(.ListFillRange)
lngI = .ListIndex
If lngI < .ListCount - 1 Then
strTmp = .List(lngI + 1)
rng.Cells(lngI + 2, 1) = .List(lngI)
rng.Cells(lngI + 1, 1) = strTmp
.ListIndex = lngI + 1
End If
End With
End Sub
Gruß Sepp