kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
In the post at:
I was looking for a way around getting advanced Filter to work for dates stored as texts in the format "dd-mm-yy".
According to @Marc L, it is not a good idea to store dates as texts. But looking at the situation I was facing, to me, it was the way to go. So I kept trying until I was able to get it working by using some for loops to compare the text dates with my input then once it matches, I copy the range i want - which is working cool atm.
My challenge now is that in case I want to get data that falls between two dates, I don't know how to do that.
I think if I am able to:
1. List all the dates between two dates - my input is like this:
>>> date1, date2 in the format dd-mm-yy. <<<
ie vDate is the variable that takes the dates .
2. I can then run my date against those on the sheet (text dates) to see if they match any of the dates I have generated from the two user input dates.
**** The first date will always be smaller than the second
Can someone please help me with this challenge?
Thanks in advance.
VBA AdvancedFiltering faling to work after changing the format of cells.
Sub filterDate() sh.[O2] = "=COUNTIF(E4:N4,TODAY())=0" Application.ScreenUpdating = False lr = sh.Range("B" & Rows.Count).End(xlUp).Row If lr < 3 Then lr = 3 With sh.Range("B3:N" & lr) .AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=sh.[O1:O2]...
www.mrexcel.com
According to @Marc L, it is not a good idea to store dates as texts. But looking at the situation I was facing, to me, it was the way to go. So I kept trying until I was able to get it working by using some for loops to compare the text dates with my input then once it matches, I copy the range i want - which is working cool atm.
My challenge now is that in case I want to get data that falls between two dates, I don't know how to do that.
I think if I am able to:
1. List all the dates between two dates - my input is like this:
>>> date1, date2 in the format dd-mm-yy. <<<
ie vDate is the variable that takes the dates .
2. I can then run my date against those on the sheet (text dates) to see if they match any of the dates I have generated from the two user input dates.
**** The first date will always be smaller than the second
Can someone please help me with this challenge?
Thanks in advance.