Hey
I use this code to filter data in a combobox. It works great!!
However...
Now i want to use this line
And filter a date compared to todays date.
The question is this:
In column X i have dates of when my staff contracts are ending.
I want to filter out all dates in column X that are between todays date and 3 months ahead.
How can i do this?
I use this code to filter data in a combobox. It works great!!
Code:
Sub FilterPersonellListBox_Larare()
Dim ws As Worksheet
Dim lr As Long
Dim FiltRng As Range
Dim R As Range
Personalform.ListBox_listapersonal.Clear 'clear listbox
Set ws = Sheets("REGISTER")
Personalform.ListBox_listapersonal.ColumnCount = 4
Personalform.ListBox_listapersonal.ColumnWidths = "1;70;70;55"
With ws
lr = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
Set FiltRng = Sheets("REGISTER").Range("N3:N" & lr)
FiltRng.AutoFilter Field:=14, Criteria1:="Lärare"
On Error Resume Next
For Each R In FiltRng.Offset(1).SpecialCells(xlCellTypeVisible).Cells
With Personalform.ListBox_listapersonal
.AddItem
.List(.ListCount - 1, 0) = ws.Cells(R.Row, "AL")
.List(.ListCount - 1, 1) = ws.Cells(R.Row, "B")
.List(.ListCount - 1, 2) = ws.Cells(R.Row, "C")
.List(.ListCount - 1, 3) = ws.Cells(R.Row, "R")
End With
Next R
On Error GoTo 0
FiltRng.AutoFilter
End With
End Sub
However...
Now i want to use this line
Code:
FiltRng.AutoFilter Field:=14, Criteria1:="Lärare"
And filter a date compared to todays date.
The question is this:
In column X i have dates of when my staff contracts are ending.
I want to filter out all dates in column X that are between todays date and 3 months ahead.
How can i do this?