AW: Höchstes, niedrigstes Datum mit Bedingungen
05.11.2016 21:05:27
Peter
Hallo Olga,
versuche es mit dem nachfolgenden Code:
Private Sub CommandButton1_Click()
Dim lZeile As Long
Dim lMinDate As Long
Dim lMaxDate As Long
Dim lWorkdays As Long
Dim Tageges As Long
lMaxDate = 1
lMinDate = 999999
With ThisWorkbook.Worksheets("Arbeitzeit")
For lZeile = 2 To .Cells(.Rows.Count, 6).End(xlUp).Row
If .Cells(lZeile, 2) = cboMonat And .Cells(lZeile, 6) = cboMonteur Then
If CLng(.Cells(lZeile, 3).Value) lMaxDate Then _
lMaxDate = CLng(.Cells(lZeile, 3).Value)
End If
Next lZeile
End With
With Sheets("F")
.Cells(2, 9) = CDate(lMinDate)
.Cells(3, 9) = CDate(lMaxDate)
Tageges = .Cells(4, 9)
End With
UFAZ.lblArbTage.Caption = "vom " & Format(lMinDate, "dd.mm.yyyy") & " bis " & Format( _
lMaxDate, "dd.mm.yyyy") & " = " & Tageges & " Arbeitstage"
End Sub
Gruß Peter