ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Equlivelent to .NewIndex Property in VBA Excel ? (https://www.excelbanter.com/excel-programming/312044-equlivelent-newindex-property-vba-excel.html)

Pawelski

Equlivelent to .NewIndex Property in VBA Excel ?
 
I am trying to make a listbox which is populated from a named range in
Excel that can then be reordered by clicking and dragging rows in the
listbox. I have found VB code that can do it, but when I tred to
recreate it in VBA I found that one of the properties, .NewIndex, does
not seem to exist in VBA. Here is the code with the nonexistant
property in it:


Private Sub ListBox1_Click()

End Sub

Private Sub ListBox1_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
With ListBox1
DragIndex = .ListIndex
End With
End Sub

Private Sub ListBox1_MouseUp(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
With ListBox1
If DragIndex < .ListIndex Then
ListTest = .List(DragIndex)
.RemoveItem DragIndex
.AddItem ListText, .ListIndex + Abs(Shift = vbShiftMask)
.ListIndex = .NewIndex '<----**THIS IS THE PROBLEM**---<
End If
End With
End Sub

Private Sub UserForm_Click()

End Sub

Can anyone show this complete newbe a way around this missing
property?

Paul


All times are GMT +1. The time now is 04:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com