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

#### NamssoB

##### Board Regular
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
27.4 KB · Views: 5

#### NamssoB

##### Board Regular
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!

### Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

#### Peter_SSs

##### MrExcel MVP, Moderator
You're welcome. Thanks for the confirmation.

Replies
2
Views
81
Replies
0
Views
54
Replies
1
Views
99
Replies
2
Views
136
Replies
5
Views
42

1,127,498
Messages
5,625,123
Members
416,073
Latest member
JosGosth98

### 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.

### Which adblocker are you using?

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

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