Looking for formula confirmation

stapuff

Well-known Member
Joined
Feb 19, 2004
Messages
1,126
I wrote the following and it appears to be giving me the correct result, but.................

My criteria = I want to see all the results from (Current Month - 2) to Today. (5/1/2007 - Today)

Between DateSerial(Year(Now()),Month(Now())-2,1) And DateSerial(Year(Now()),Month(Now())+1,0)

Looking for someone to confirm or suggest.

Thanks,

Kurt
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

LxQ

Well-known Member
Joined
Feb 9, 2006
Messages
619
this seems to work well unless you're in January, and the Year(Now()) function will mess you up if you're looking for a prior year month.
 

VicRauch

Well-known Member
Joined
Mar 23, 2006
Messages
2,032
You say you want the "To" date to be 5/1/07 because that is Today. But your expression gives the last day of the current month. Do you want it to be Today, or the last day of the current month? For Today, all you need would be Date() rather than going through the DateSerial function.

When I looked at your expression, I agreed with LxQ. But then I tested it, and found that in January of 2007, by subtracting 2 from the 1 for January, I ended up in Nov 1, 2006. So DateSerial will take the -1 for a month in 2007 and give you the correct month and year. VERY NICE job from Microsoft. Would not have believed it if I had not seen it.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,507
Messages
5,837,750
Members
430,515
Latest member
K_Lynch

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
Top