The following line of code will allocate an array as one dimensional sortedArr = WorksheetFunction.Transpose(lstIssues1.List)
. This line of code allocates an array as two dimensional arrIssues = Table.ListColumns(Table.ListColumns(strNumber).Range.column).DataBodyRange
For each of the above lines I call a bubble sort function. But it errors on one or the other depending on whether I put
If Arr(i) > Arr(j) Then ...
Or
If Arr(i, 1) > Arr(j, 1) Then ...
I can loop to fill arrIssues
. But I am wondering if it's possible to fill it as a one dimensional array without looping.
UPDATE
Here is the code I am having trouble with
Private Sub cmdRemove_Click()
Dim SortedArr() As Variant
With lstPrevious
If .ListIndex = -1 Then Exit Sub
For i = .ListCount - 1 To 0 Step -1
If .Selected(i) = True Then
lstAdditional.AddItem .List(i)
.RemoveItem (i)
End If
Next i
End With
ReDim SortedArr(lstAdditional.ListCount - 1)
SortedArr = Application.Transpose(lstAdditional.List) 'ERROR Type Mismatch
Call BubbleSort(SortedArr)
Me.lstAdditional.List = SortedArr
txtFocus.SetFocus
End Sub
Public Sub BubbleSort(Arr)
Dim strTemp As String
Dim lngMin As Long
Dim lngMax As Long
lngMin = LBound(Arr)
lngMax = UBound(Arr)
For i = lngMin To lngMax
For j = i + 1 To lngMax
If Arr(i) > Arr(j) Then
strTemp = Arr(i)
Arr(i) = Arr(j)
Arr(j) = strTemp
End If
Next j
Next i
End Sub
Strangely, I use the same logic in another userform and it works. Sorry for the lack of clarity.