2.1k Aufrufe
Gefragt in Windows2000 von
Guten Morgen!

Hab da ein kleines Problem. Will das Datum über Autofilter mit UserForm Filtern. Das heißt ich hab 2 Textboxen zur Eingabe vom Datum und will nun die Spalte M nach Anfangsdatum und Enddatum Filtern. Kann mir jemand weiterhelfen

1 Antwort

0 Punkte
Beantwortet von micha70 Einsteiger_in (5 Punkte)
Will mal den Code hochladen!

Option Explicit

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim dDatum_Von As Date
Dim dDatum_Bis As Date
Dim WkSh As Worksheet
Dim lLetzte As Long
Dim LZeile As Long
Dim rSuchBer As Range
Dim rHide As Range

dDatum_Von = CLng(CDate(TextBox1.Text))
dDatum_Bis = CLng(CDate(TextBox2.Text))



If Trim(TextBox1.Value) <> "" Then
If IsDate(TextBox1.Value) Then
dDatum_Von = TextBox1.Value
Else
MsgBox "Die Von DatumBox enthält keine kalendarisch richtiges Datum."
With TextBox1
.SetFocus
.SelStart = 0
.SelLength = Len(.Value)
End With
Exit Sub
End If
Else
MsgBox "Die TextBox1 enthält keine Eingabe.", _
16, " Hinweis für " & Application.UserName
TextBox1.SetFocus
Exit Sub
End If

If Trim(TextBox2.Value) <> "" Then
If IsDate(TextBox2.Value) Then
dDatum_Bis = TextBox2.Value
Else
MsgBox "Die Bis DatumBox enthält keine kalendarisch richtiges Datum."

With TextBox2
.SetFocus
.SelStart = 0
.SelLength = Len(.Value)
End With
Exit Sub
End If
Else
MsgBox "Die TextBox2 enthält keine Eingabe.", _
16, " Hinweis für " & Application.UserName
TextBox2.SetFocus
Exit Sub
End If

Set WkSh = ThisWorkbook.Worksheets("Tabelle1")
WkSh.Activate

If WkSh.FilterMode = True Then WkSh.Range("A4").AutoFilter

WkSh.Range("A4").AutoFilter
WkSh.Range("A4").AutoFilter Field:=1, VisibleDropdown:=False
WkSh.Range("A4").AutoFilter Field:=1, _
Criteria1:=">=" & CLng(CDate(TextBox1.Text)), _
Operator:=xlAnd, _
Criteria2:="<=" & CLng(CDate(TextBox2.Text)), _
VisibleDropdown:=False


End Sub
...