SaurabhPandit
New Member
- Joined
- Dec 20, 2021
- Messages
- 6
- Office Version
- 365
- Platform
- Windows
Hello Everyone,
I am a little bit struggling to put a date range filter in VBA. There are total of 3 sheets. One is Summary where I want to put start date(e5) and End date(g5). All data is in a Lithology sheet which I need to filter. And Sheet LithoFilter is where I want to paste filtered data.
Where I am going wrong? Can anyone help me with this?
Thank You
Sub AllGeoFileter()
Sheets("Lithology").Select
Range("A1:BZ50000").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
>=sheets ("Summary").Range("e5"), Operator:=xlAnd, Criteria2:= <=sheets ("Summary").Range("f5")
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("LithoFilter").Select
Range("a1").Select
Selection.PasteSpecial xlPasteValues
End Sub
I am a little bit struggling to put a date range filter in VBA. There are total of 3 sheets. One is Summary where I want to put start date(e5) and End date(g5). All data is in a Lithology sheet which I need to filter. And Sheet LithoFilter is where I want to paste filtered data.
Where I am going wrong? Can anyone help me with this?
Thank You
Sub AllGeoFileter()
Sheets("Lithology").Select
Range("A1:BZ50000").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
>=sheets ("Summary").Range("e5"), Operator:=xlAnd, Criteria2:= <=sheets ("Summary").Range("f5")
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("LithoFilter").Select
Range("a1").Select
Selection.PasteSpecial xlPasteValues
End Sub