The CompareRows event allows you to make comparisons on other than the default basis. You get variables row1, row2, and column to tell you what is about to be compared, and a ByRef result to put the answer in, so…
if column = kMyNumericColumn then
dim a1, a2 as double
a1 = CDbl(me.Cell(row1,column))
a2 = CDbl(me.Cell(row3,column))
if a1<a2 then
result = -1
elseif a1>a2 then
result = 1
else
result = 0
end if
return true //this means you actually did a comparison
else
return false //if it's not the numeric column, this tells the program to go ahead and use the default sort
end if
I just see that if we return 0 (result = 0) then the listbox is sometimes sorted.
Make a listbox with 2 or 3 columns with anything in them.
Enter in the event CompareRows
result = 0
then launch and click the header to sort. Click one time on a column, nothing happens (depending of ascending or descending), click again, it’s sorted. Clicxk again, nothing more happens (it stay sorted as it is).
Click another columns, same trouble (depending of ascending or descending).
Where can I download Paul’s project? I watched the excellent video, but the youtube page sends me back to the list of videos, and I do not see the project on the video list page.