Filtering by moving date across multiple columns

CaraM

New Member
Joined
Apr 8, 2018
Messages
33
Office Version
  1. 365
Platform
  1. Windows
I have a feeling that this isn't complicated, but I'm just not thinking about it correctly. I have a sheet of my tasks, with lots of autofiltering going on via VBA that is working fine.

Now, I want to look at two different date columns (LastModified and StartDate) and filter my tasks where EITHER contains a recent (but not future) date. So:
Lastmodified > today()-1 OR (StartDate >=today()-1 AND StartDate <=today()+1)

I can't use AutoFilter for this, right, because it's an OR query against different fields?

I can't really use Advanced Filter, can I? Because the date is relative and not fixed. Plus, I really don't want to have to have a criteria range - it seems like I should be able to do this in code.

And -- is there some way to use PowerQuery through VBA to accomplish this?

Again - seems like this should be simple, but I cannot see what I'm missing.

I did TRY the Advanced Filter. I put LastModified and StartDate column headers in a new sheet, put this in my criteria range, and it looked weird at first but I believe the results were right. But that date has to move. Do I have to code a specific date entry into the criteria formulas? Is there a "cleaner" way?
LastModified

<tbody>
</tbody>
STARTDATE

<tbody>
</tbody>
=">=2/19/2019"
=">=2/19/2019,<=2/20/2019"

<tbody>
</tbody>






Thanks
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Re: Questions about filtering by moving date across multiple columns

hi CaraM,

can you not use today() in your formula?
=">="&today() or
=">="&TEXT(TODAY(),"dd//mm/yy")
 
Upvote 0
Re: Questions about filtering by moving date across multiple columns

sijpie,

It sure seems like I should be able to. But I need >=yesterday in the LastModified criteria, and between yesterday and tomorrow in the StartDate criteria and, when I use today()-1 and today()+1 to try to get those date, I get no data returned, though I should.

In addition, it sure feels like mixing advanced filters and autofilters is messing with my code. I'm not able to determine when filters are on or off, since adding the Advanced Filter.
 
Upvote 0
Re: Questions about filtering by moving date across multiple columns

yesterday = today()-1

so the formula would become:
=">="&TEXT(TODAY()-1,"DD/MM/YY")
 
Upvote 0
Re: Questions about filtering by moving date across multiple columns

Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,148
Members
448,552
Latest member
WORKINGWITHNOLEADER

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top