I have this code to alphabetize list values then add them back. I keep getting an error Run-time error 9 Subscript out of range. On line If Ray(j) < Ray(i) And Ray(j) <> "" . I have this working in many other parts of this project but the list is a range. Ray = Range("N2:N" & LastRow).Value
Dim Ray, i As Integer, j As Integer, Temp As String
Ray = lbOFFICE.List
lbOFFICE.Clear
'MsgBox lbOFFICE.List
For i = 1 To UBound(Ray) - 1
For j = i To UBound(Ray)
If Ray(j) < Ray(i) And Ray(j) <> "" Then
Temp = Ray(i)
Ray(i) = Ray(j)
Ray(j) = Temp
End If
Next j
Next i
lbOFFICE.List = Ray
Dim Ray, i As Integer, j As Integer, Temp As String
Ray = lbOFFICE.List
lbOFFICE.Clear
'MsgBox lbOFFICE.List
For i = 1 To UBound(Ray) - 1
For j = i To UBound(Ray)
If Ray(j) < Ray(i) And Ray(j) <> "" Then
Temp = Ray(i)
Ray(i) = Ray(j)
Ray(j) = Temp
End If
Next j
Next i
lbOFFICE.List = Ray