1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
| Private Sub CmdLineSortOk_Click()
Dim column_index1 As String
Dim column_index2 As String
Dim column_index3 As String
Dim number As Integer
Dim last_line As Integer
Dim i As Integer
Sheets("Copie").Visible = True
Sheets("Copie").Select
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Clear
Sheets("Workload").Select
Range("A10").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Copie").Select
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Visible = False
Sheets("Workload").Select
last_line = Range("B65536").End(xlUp).Row
Rows("10:" & last_line).Select
If CboCol1.Value <> "" And CboCol2.Value = "" And CboCol3.Value = "" Then number = 1
If CboCol1.Value <> "" And CboCol2.Value <> "" And CboCol3.Value = "" Then number = 2
If CboCol1.Value <> "" And CboCol2.Value <> "" And CboCol3.Value <> "" Then number = 3
If number = 1 Then
If CboCol1.Value = "Date" Then column_index1 = "A10"
If CboCol1.Value = "Program" Then column_index1 = "B10"
If CboCol1.Value = "BU" Then column_index1 = "C10"
If CboCol1.Value = "Phasis" Then column_index1 = "D10"
If CboCol1.Value = "Type of program" Then column_index1 = "E10"
If CboCol1.Value = "a" Then column_index1 = "F10"
If CboCol1.Value = "b" Then column_index1 = "G10"
If CboCol1.Value = "Project" Then column_index1 = "H10"
If CboCol1.Value = "Activity" Then column_index1 = "I10"
If CboCol1.Value = "Working Modes" Then column_index1 = "J10"
If CboCol1.Value = "Design maturity" Then column_index1 = "K10"
If CboCol1.Value = "Pro ex" Then column_index1 = "L10"
If CboCol1.Value = "Pro el" Then column_index1 = "M10"
If CboCol1.Value = "Internal Pro" Then column_index1 = "N10"
If CboCol1.Value = "Probability" Then column_index1 = "O10"
If FrCol1.OptCol1Asc.Value = True Then
Selection.Sort Key1:=Range(column_index1), order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Else
Selection.Sort Key1:=Range(column_index1), order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End If
End If
If number = 2 Then
If CboCol1.Value = "Date" Then column_index1 = "A10"
If CboCol1.Value = "Program" Then column_index1 = "B10"
If CboCol1.Value = "BU" Then column_index1 = "C10"
If CboCol1.Value = "Phasis" Then column_index1 = "D10"
If CboCol1.Value = "Type of program" Then column_index1 = "E10"
If CboCol1.Value = "a" Then column_index1 = "F10"
If CboCol1.Value = "b" Then column_index1 = "G10"
If CboCol1.Value = "Project" Then column_index1 = "H10"
If CboCol1.Value = "Activity" Then column_index1 = "I10"
If CboCol1.Value = "Working Modes" Then column_index1 = "J10"
If CboCol1.Value = "Design maturity" Then column_index1 = "K10"
If CboCol1.Value = "Pro ex" Then column_index1 = "L10"
If CboCol1.Value = "Pro el" Then column_index1 = "M10"
If CboCol1.Value = "Internal Pro" Then column_index1 = "N10"
If CboCol1.Value = "Probability" Then column_index1 = "O10"
If CboCol2.Value = "Date" Then column_index2 = "A10"
If CboCol2.Value = "Program" Then column_index2 = "B10"
If CboCol2.Value = "BU" Then column_index2 = "C10"
If CboCol2.Value = "Phasis" Then column_index2 = "D10"
If CboCol2.Value = "Type of program" Then column_index2 = "E10"
If CboCol2.Value = "a" Then column_index2 = "F10"
If CboCol2.Value = "b" Then column_index2 = "G10"
If CboCol2.Value = "Project" Then column_index2 = "H10"
If CboCol2.Value = "Activity" Then column_index2 = "I10"
If CboCol2.Value = "Working Modes" Then column_index2 = "J10"
If CboCol2.Value = "Design maturity" Then column_index2 = "K10"
If CboCol2.Value = "Pro ex" Then column_index2 = "L10"
If CboCol2.Value = "Pro el" Then column_index2 = "M10"
If CboCol2.Value = "Internal Pro" Then column_index2 = "N10"
If CboCol2.Value = "Probability" Then column_index2 = "O10"
If FrCol1.OptCol1Asc.Value = True And FrCol2.OptCol2Asc.Value = True Then
Selection.Sort Key1:=Range(column_index1), order1:=xlAscending, Key2:=Range(column_index2 _
), order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
End If
If FrCol1.OptCol1Asc.Value = True And FrCol2.OptCol2Asc.Value = False Then
Selection.Sort Key1:=Range(column_index1), order1:=xlAscending, Key2:=Range(column_index2 _
), order2:=xlDescending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
End If
If FrCol1.OptCol1Asc.Value = False And FrCol2.OptCol2Asc.Value = True Then
Selection.Sort Key1:=Range(column_index1), order1:=xlDescending, Key2:=Range(column_index2 _
), order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
End If
If FrCol1.OptCol1Asc.Value = False And FrCol2.OptCol2Asc.Value = False Then
Selection.Sort Key1:=Range(column_index1), order1:=xlDescending, Key2:=Range(column_index2 _
), order2:=xlDescending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
End If
End If
If number = 3 Then
If CboCol1.Value = "Date" Then column_index1 = "A10"
If CboCol1.Value = "Program" Then column_index1 = "B10"
If CboCol1.Value = "BU" Then column_index1 = "C10"
If CboCol1.Value = "Phasis" Then column_index1 = "D10"
If CboCol1.Value = "Type of program" Then column_index1 = "E10"
If CboCol1.Value = "a" Then column_index1 = "F10"
If CboCol1.Value = "b" Then column_index1 = "G10"
If CboCol1.Value = "Project" Then column_index1 = "H10"
If CboCol1.Value = "Activity" Then column_index1 = "I10"
If CboCol1.Value = "Working Modes" Then column_index1 = "J10"
If CboCol1.Value = "Design maturity" Then column_index1 = "K10"
If CboCol1.Value = "Pro ex" Then column_index1 = "L10"
If CboCol1.Value = "Pro el" Then column_index1 = "M10"
If CboCol1.Value = "Internal Pro" Then column_index1 = "N10"
If CboCol1.Value = "Probability" Then column_index1 = "O10"
If CboCol2.Value = "Date" Then column_index2 = "A10"
If CboCol2.Value = "Program" Then column_index2 = "B10"
If CboCol2.Value = "BU" Then column_index2 = "C10"
If CboCol2.Value = "Phasis" Then column_index2 = "D10"
If CboCol2.Value = "Type of program" Then column_index2 = "E10"
If CboCol2.Value = "a" Then column_index2 = "F10"
If CboCol2.Value = "b" Then column_index2 = "G10"
If CboCol2.Value = "Project" Then column_index2 = "H10"
If CboCol2.Value = "Activity" Then column_index2 = "I10"
If CboCol2.Value = "Working Modes" Then column_index2 = "J10"
If CboCol2.Value = "Design maturity" Then column_index2 = "K10"
If CboCol2.Value = "Pro ex" Then column_index2 = "L10"
If CboCol2.Value = "Pro el" Then column_index2 = "M10"
If CboCol2.Value = "Internal Pro" Then column_index2 = "N10"
If CboCol2.Value = "Probability" Then column_index2 = "O10"
If CboCol3.Value = "Date" Then column_index3 = "A10"
If CboCol3.Value = "Program" Then column_index3 = "B10"
If CboCol3.Value = "BU" Then column_index3 = "C10"
If CboCol3.Value = "Phasis" Then column_index3 = "D10"
If CboCol3.Value = "Type of program" Then column_index3 = "E10"
If CboCol3.Value = "a" Then column_index3 = "F10"
If CboCol3.Value = "b" Then column_index3 = "G10"
If CboCol3.Value = "Project" Then column_index3 = "H10"
If CboCol3.Value = "Activity" Then column_index3 = "I10"
If CboCol3.Value = "Working Modes" Then column_index3 = "J10"
If CboCol3.Value = "Design maturity" Then column_index3 = "K10"
If CboCol3.Value = "Pro ex" Then column_index3 = "L10"
If CboCol3.Value = "Pro el" Then column_index3 = "M10"
If CboCol3.Value = "Internal Pro" Then column_index3 = "N10"
If CboCol3.Value = "Probability" Then column_index3 = "O10"
If FrCol1.OptCol1Asc.Value = True And FrCol2.OptCol2Asc.Value = True And FrCol3.OptCol3Asc.Value = True Then
Selection.Sort Key1:=Range(column_index1), order1:=xlAscending, Key2:=Range(column_index2 _
), order2:=xlAscending, Key3:=Range(column_index3), order3:=xlAscending, Header _
:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom _
, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End If
If FrCol1.OptCol1Asc.Value = True And FrCol2.OptCol2Asc.Value = True And FrCol3.OptCol3Asc.Value = False Then
Selection.Sort Key1:=Range(column_index1), order1:=xlAscending, Key2:=Range(column_index2 _
), order2:=xlAscending, Key3:=Range(column_index3), order3:=xlDescending, Header _
:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom _
, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End If
If FrCol1.OptCol1Asc.Value = True And FrCol2.OptCol2Asc.Value = False And FrCol3.OptCol3Asc.Value = False Then
Selection.Sort Key1:=Range(column_index1), order1:=xlAscending, Key2:=Range(column_index2 _
), order2:=xlDescending, Key3:=Range(column_index3), order3:=xlDescending, Header _
:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom _
, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End If
If FrCol1.OptCol1Asc.Value = False And FrCol2.OptCol2Asc.Value = False And FrCol3.OptCol3Asc.Value = False Then
Selection.Sort Key1:=Range(column_index1), order1:=xlDescending, Key2:=Range(column_index2 _
), order2:=xlDescending, Key3:=Range(column_index3), order3:=xlDescending, Header _
:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom _
, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End If
If FrCol1.OptCol1Asc.Value = True And FrCol2.OptCol2Asc.Value = False And FrCol3.OptCol3Asc.Value = True Then
Selection.Sort Key1:=Range(column_index1), order1:=xlAscending, Key2:=Range(column_index2 _
), order2:=xlDescending, Key3:=Range(column_index3), order3:=xlAscending, Header _
:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom _
, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End If
If FrCol1.OptCol1Asc.Value = False And FrCol2.OptCol2Asc.Value = False And FrCol3.OptCol3Asc.Value = True Then
Selection.Sort Key1:=Range(column_index1), order1:=xlDescending, Key2:=Range(column_index2 _
), order2:=xlDescending, Key3:=Range(column_index3), order3:=xlAscending, Header _
:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom _
, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End If
End If
End Sub |
Partager