Ich möchte über eine Inputbox das Startdatum eingeben und alle Geb-Daten filtern, die innerhalb dieses Zeitraumes bis zum heutigen Datum liegen.
Vielen Dank im Voraus.
Servus
https://www.herber.de/bbs/user/162182.xlsm
Sub BedingteFormatierung_Einrichten()
With Columns("J:J")
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=UND(TEXT(J1;""MMTT"")=TEXT(HEUTE();""MMTT"");TEXT(J1;""MMTT"")>=DatumAb)"
.FormatConditions(.FormatConditions.Count).Font.Color = Farbe
End With
End Sub
Sub Eingabe()
Dim txt
Do
txt = InputBox("Datum ab eingeben")
If txt = "" Then Exit Do
If IsDate(txt) Then
ThisWorkbook.Names.Add "DatumAb", RefersToR1C1:="=""" & Format(CDate(txt), "MMDD") & """"
ActiveSheet.Range("J:J").AutoFilter Field:=1, Criteria1:=Farbe, Operator:=xlFilterFontColor
ThisWorkbook.Names("DatumAb").Delete
Exit Do
Else
MsgBox "Bitte korrektes Datum eingeben"
End If
Loop
End Sub
=Text($A$1;"MMTT")
=UND(TEXT(J1;""MMTT"")=TEXT(HEUTE();""MMTT"");TEXT(J1;""MMTT"")>=DatumAb)
Option Explicit
Const Farbe AS long = vbRed
=FILTER(A2:AA395;(TEXT(J2:J395;"MMTT")>="0802")*(TEXT(J2:J395;"MMTT")=TEXT(HEUTE();"MMTT")))
A | B | C | D | E | |
1 | shift-del | 24.12.1971 | flotterfeger | 31.10.1995 | |
2 | slowboarder | 02.02.1984 | shift-del | 24.12.1971 | |
3 | steve1da | 05.05.1976 | slowboarder | 02.02.1984 | |
4 | lupo1 | 06.02.1999 | |||
5 | oberon | 03.04.1968 | |||
6 | steuerfuzzi | 16.06.1972 | |||
7 | flotterfeger | 31.10.1995 | |||
8 | rpp63 | 03.05.1963 |
Zelle | Formel |
D1 | =LET(m;"MMTT";
INDEX(SORTIERENNACH(A1:B8; TEXT(B1:B8;m)+(TEXT(B1:B8;m)TEXT(HEUTE();m))*10^4); {1;2;3};{1.2})) |
Sub Geburtstag_filtern()
Dim GebSpalte As Range, SuchSpalte As Range, s As Range, Von As String
Dim Tag As Integer, Monat As Integer, VonDatum As Date, GebDatum As Date, Heute As Date
Von = InputBox("Geburtstag von..." & vbCr & "Bitte im Format TT.MM. eingeben")
If Von = "" Then
Cells.EntireRow.Hidden = False
Exit Sub
End If
Tag = Left(Von, 2)
Monat = Mid(Von, 4, 2)
VonDatum = DateSerial(Year(Date), Monat, Tag)
Heute = DateSerial(Year(Date), Month(Date), Day(Date))
Set GebSpalte = Cells.Find(What:="Geb. Datum", After:=Range("A1"), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
Set SuchSpalte = Intersect(ActiveSheet.UsedRange, GebSpalte.EntireColumn)
' SuchSpalte.Select
For Each s In SuchSpalte
' s.Select
If IsDate(s) = True Then
GebDatum = DateSerial(Year(Date), Month(s), Day(s))
If GebDatum >= VonDatum And GebDatum = Heute Then
s.EntireRow.Hidden = False
Else
s.EntireRow.Hidden = True
End If
End If
Next s
End Sub
Private Sub CommandButton1_Click()
Dim z, Tag, mon, t, m, dat, Von, da
t = Range("AG1"): m = Range("AI1")
Application.ScreenUpdating = False
For z = 2 To 1000
dat = Cells(z, "J")
If dat > "" Then
Cells(z, "J").Rows.Hidden = False
Tag = Day(dat): mon = Month(dat)
If Not CheckBox1 Then
If Tag > t Or mon > m Then Cells(z, "J").Rows.Hidden = True
Else
da = DateSerial(Year(Date), mon, Tag)
Von = DateSerial(Year(Date), m, t)
If da > Date Or da Von Then Cells(z, "J").Rows.Hidden = True
End If
End If
Next z
End Sub
Dim Von As Date
With Sheets("Tab1")
If .FilterMode Then .ShowAllData ' Autofilter alle
Von = InputBox("Geburtstag von...")
If IsDate(Von) Then
.Range("J:J").AutoFilter Field:=1, Criteria1:=">=" & CLng(Von), _
Operator:=xlAnd, Criteria2:="=" & CLng(Date)
End If
End With
Arbeitsblatt mit dem Namen 'Tab1' | |||||||||||||||||||||
I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | AA | AB | AC | |
1 | Geb. Datum | Alter | |||||||||||||||||||
2 | 07.12.1973 | 49 | 07.12.2023 | ||||||||||||||||||
3 | 30.05.1985 | 38 | 30.05.2023 | ||||||||||||||||||
4 | 22.09.1982 | 40 | 22.09.2023 | ||||||||||||||||||
5 | 23.11.1957 | 65 | 23.11.2023 | ||||||||||||||||||
6 | 28.07.1963 | 60 | 28.07.2023 | ||||||||||||||||||
7 | 17.03.1964 | 59 | 17.03.2023 | ||||||||||||||||||
8 | 19.07.1976 | 47 | 19.07.2023 |
Zelle | Formel |
AC2 | =DATUM(JAHR(HEUTE());MONAT(J2);TAG(J2)) |
Dim Von As Variant
With Sheets("Tab1")
If .FilterMode Then .ShowAllData ' Autofilter alle
Von = InputBox("Geburtstag von...10.06.")
Von = DateValue(Von & Year(Date))
If IsDate(Von) Then
.Range("AC:AC").AutoFilter Field:=1, Criteria1:=">=" & CLng(Von), _
Operator:=xlAnd, Criteria2:="=" & CLng(Date)
End If
End With
Sub Makro1()
Dim Von As Date
With Sheets("Tab1")
If .FilterMode Then .ShowAllData ' Autofilter alle
Von = InputBox("Geburtstag von...")
If IsDate(Von) Then
.Range("N:N").AutoFilter Field:=2, _
Criteria1:=">=" & Von, Operator:=xlAnd, _
Criteria2:="=" & Format(Date, "MMDD")
End If
End With
End Sub