Sum a range based on another column with dates where the MONTH matches a drop down list in another cell?

NamssoB

Board Regular
Joined
Jul 8, 2005
Messages
76
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a list of stock trades, all dated in column O (from O5:O5000). I have a profit/loss in column U starting at U5. I have a drop down in U1 to select Month (3-letter abbreviation), as well as the word "Total". My goal is to be able to select Jan from the drop down, and have it show me my profit from January. Change to Feb, and I only see profit from Feb. Change to Total, and it shows me total profit.

I want to select Jan, Feb, Mar, etc., in the drop down, and have cell U2 show me a total for all items with a date within the month selected in the drop down. For example:

U1: Drop down, with a list (Total, Jan, Feb, Mar, ...)
U2: Formula I'm trying to figure out: SUM U5:U5000 for any entries with a date (Column O5:O5000, 12-Feb, 5-Jan, etc) that matches the month selected in U1
U5... Values I want to sum
O5... Dates

I know I can use TEXT(O5,"mmm") to grab the 3-letter month and compare it to U1, but I can't figure out how to get that into my formula in U2.

And when I select Total in U2, I just want to add everything up, the entire column U starting at U5.

Ideas?
 

Attachments

  • Capture.PNG
    Capture.PNG
    27.4 KB · Views: 80
Just change all the references to row 5 in my formula to row 4 and you still shouldn't need OFFSET.

=SUM(FILTER(U4:INDEX(U:U,5000),IF(U1="Total",O4:INDEX(O:O,5000)<>"",(TEXT(O4:INDEX(O:O,5000),"mmm")=U1)*(O4:INDEX(O:O,5000)<>"")),0))
That worked - thank you!
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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