online 1
gast (50)

/ Forum / Windows classik

Windows classikWindows classik

Fragevon Micha70 vom 23.10.2022, 08:46 Options

VBA Datum Filtern von bis über Userform

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


Antwort schreiben

Antwort 1 von Micha70 vom 23.10.2022, 10:08 Options

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

Ähnliche Themen

Scanner
biebe011  14.04.2009 - 292 Hits - 2 Antworten

passwort
Knatterwald  05.06.2009 - 516 Hits - 1 Antwort

paswort ändern
danny-helms  22.04.2009 - 349 Hits - 1 Antwort

Datumsprobleme
jan_s  28.04.2009 - 285 Hits - 13 Antworten

Hinweis

Diese Frage ist schon etwas älter, Sie können daher nicht mehr auf sie antworten. Sollte Ihre Frage noch nicht gelöst sein, stellen Sie einfach eine neue Frage im Forum..

Neue Einträge

Version: supportware 1.9.150 / 10.06.2022, Startzeit:Mon Jan 26 01:23:17 2026