Keep selected row with TableSort

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Is it possible to do a table sort and keep the currently selected row selected?
I know I could do that by putting the cells of that row in a variable and then after the sort loop through the table, find that row and select it, but that would be too slow.

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Actually performance is not bad when I do code like this:

Before the sort:

Sub MarkPreSortRow(lRow)

Table1.AddCol(cNumber, "MarkPreSortRow", 0, False)
Table1.Cell("MarkPreSortRow", lRow) = 1

End Sub


And after the sort:

Sub SelectPreSortTableRow(strColumnName)

Dim i

For i = 0 To Table1.RowCount - 1
If Table1.Cell("MarkPreSortRow", i) = 1 Then
Table1.RemoveCol("MarkPreSortRow")
Table1.SelectCell(strColumnName, i)
Return
End If
Next i

End Sub


And I take it there is nothing better than this.


RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Good point. Some of the tables indeed have a unique key and in that case I could maybe save a bit of time by not adding the extra column.
To add the unique key if I don't otherwise need it won't probably be worth it.

RBS
 
Top