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
| Private Sub CommandButton1_Click()
Dim i As Long
Dim lMin As Long
Dim lMax As Long
Application.ScreenUpdating = False
'On assure le coup au cas où !... trier les dates et Heures
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range( _
"A2:A14834"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range( _
"B2:B14834"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Feuil1").Sort
.SetRange Range("A1:B14834")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'============================================
Range("A1").EntireRow.Hidden = False
For i = Range("A1048576").End(xlUp).Row To 1 Step -1
Application.StatusBar = "Analyse ligne " & i
If i > 1 Then
If Cells(i, 1) + VBA.Hour(Cells(i, 2)) / 24 + VBA.Minute(Cells(i, 2)) / (24 * 60) > _
VBA.DateSerial(VBA.Year(Range("A2")), VBA.Month(Range("A2")), CLng(Me.ComboBox4.Text)) + _
VBA.CLng(Me.ComboBox5) / 24 + VBA.CLng(Me.ComboBox6) / (24 * 60) Then
lMax = i - 1
End If
If Cells(i, 1) + VBA.Hour(Cells(i, 2)) / 24 + VBA.Minute(Cells(i, 2)) / (24 * 60) < _
VBA.DateSerial(VBA.Year(Range("A2")), VBA.Month(Range("A2")), CLng(Me.ComboBox1.Text)) + _
VBA.CLng(Me.ComboBox2) / 24 + VBA.CLng(Me.ComboBox3) / (24 * 60) Then
lMin = i
Exit For
End If
End If
Next
MsgBox "Min " & lMin & " - Max " & lMax
If lMin > 2 Then
Range("A2:A" & lMin - 1).EntireRow.Hidden = True
End If
Range("A" & lMax + 1 & ":A" & Range("A1").CurrentRegion.Rows.Count).EntireRow.Hidden = True
Application.StatusBar = False
End Sub |
Partager