SORT msflexgrid by column click

User avatar
sal21
PlatinumLounger
Posts: 4356
Joined: 26 Apr 2010, 17:36

SORT msflexgrid by column click

Post by sal21 »

Code: Select all

Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)

With Me.MSFlexGrid1
        Static blAscending As Boolean

        If Button = vbLeftButton Then
            If .Row = 1 And .ColSel = 0 Then
                If Not blAscending Then
                    .Sort = flexSortNumericAscending
                    blAscending = True
                Else
                    .Sort = flexSortNumericDescending
                    blAscending = False
                End If
            End If
        End If
        End With
        
        End Sub
i use this code to sort grid by click on column 0

but i need to sort also the column 51 or 52 or 53

how to modify this code?

select case statement?

note:
all columns have only number value

User avatar
HansV
Administrator
Posts: 78494
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SORT msflexgrid by column click

Post by HansV »

Best wishes,
Hans