C
christobal
Have A listbox on a userform which has been populated from the entry o
data from 4 dropdown lists. After population is completed the listbo
contains 4 columns with "x" rows. Have added a command which allows th
user to move the selected row up in the list. The problem with th
following code is that the first column entry is moved without the dat
of the corresponding 3 columns
can any one help me on this one
------------------------------------------
Private Sub cmdup_Click()
' stores the two items
Dim SelectedData As String
Dim AboveData As String
' Stores the index of the selected item
Dim RowNumber As Integer
RowNumber = ListBox1.ListIndex
If RowNumber = 0 Then
ListBox1.SetFocus
Exit Sub
Else
SelectedData = ListBox1.List(RowNumber)
AboveData = ListBox1.List(RowNumber - 1)
'move selected data down 1 position
'(meanwhile the other data item takes its place)
ListBox1.List(RowNumber) = AboveData
ListBox1.List(RowNumber - 1) = SelectedData
' select the list item you just moved
ListBox1.Selected(RowNumber - 1) = True
ListBox1.SetFocus
End If
End Sub
data from 4 dropdown lists. After population is completed the listbo
contains 4 columns with "x" rows. Have added a command which allows th
user to move the selected row up in the list. The problem with th
following code is that the first column entry is moved without the dat
of the corresponding 3 columns
can any one help me on this one
------------------------------------------
Private Sub cmdup_Click()
' stores the two items
Dim SelectedData As String
Dim AboveData As String
' Stores the index of the selected item
Dim RowNumber As Integer
RowNumber = ListBox1.ListIndex
If RowNumber = 0 Then
ListBox1.SetFocus
Exit Sub
Else
SelectedData = ListBox1.List(RowNumber)
AboveData = ListBox1.List(RowNumber - 1)
'move selected data down 1 position
'(meanwhile the other data item takes its place)
ListBox1.List(RowNumber) = AboveData
ListBox1.List(RowNumber - 1) = SelectedData
' select the list item you just moved
ListBox1.Selected(RowNumber - 1) = True
ListBox1.SetFocus
End If
End Sub