Find Last Occurance of Given Month & Year in Range

talt0612

New Member
Joined
Nov 22, 2011
Messages
35
Hi all- I'm stuck on a problem. For a given date, how do I find the last occurance of the given dates' month and year in a range?

Here are some more details:
A1 =a random date in the format "MM/DD/YYYY".
Column B = range of dates from 1/1/2009 - today in format "MM/DD/YYYY"
Column C = a transaction value corresponding to the date in B.

The dates are in column B are in chronological order, but not all dates are listed. So for instance B1 might be 1/1/2009, B2 is 1/2/2009, but B3 is 1/7/2009 because there were no transactions from 1/3/2009 to 1/6/2009.

So if A1 is 1/1/2009, I need to look in Column B for the last transaction date in the month of Jan 2009 and return the value in column C.

Any thoughts on how I can do this in VBA. I'm using Excel 2007.

Thanks very much in advance.
 

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.
is it Monday again already??
I had the logic in my head, it just got lost somewhere between there and the keyboard...:LOL:

Yes, that formula looks MUCH better.

sorry, reverted to R1C1 here....B2= B1+3, B3=B2+3....

What if I modify the formula to :

=LOOKUP(EOMONTH(A1,0),B:C)

This seems to work even when the last two dates in the range are the same (i.e. today), but I'm not sure how, why.
 
Upvote 0

Forum statistics

Threads
1,217,441
Messages
6,136,643
Members
450,022
Latest member
Joel1122331

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