How to get a max value less than X where column A = smth...

Gedeon Kh

New Member
Joined
Apr 8, 2016
Messages
9
I have data set on excel worksheet like this:

name | date | amount
NM_1 | 01/01/2016 | 100
NM_2 | 01/01/2016 | 5000
NM_1 | 01/02/2016 | 70
NM_1 | 01/03/2016 | 50
NM_3 | 01/04/2016 | 400


My goal is to find the amount where name = NM_1 and date <= 05/01/2016:

How can I find the value in VBA ??
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Why not use AutoFilter and subtotal formula instead?
Is VBA code necessary? It would be something like:
Code:
    rng.AutoFilter Field:=1, Criteria1:="NM_1"
    rng.AutoFilter Field:=2, Criteria1:= _
        "<05/01/2016", Operator:=xlAnd
 
Upvote 0
You asked for VBA. Are you now saying that you want a formula? If so, try:

=SUMIFS(C$1:C$5,A$1:A$5,"NM_1",B$1:B$5,"<05/01/2016")
 
Upvote 0

Forum statistics

Threads
1,226,739
Messages
6,192,739
Members
453,754
Latest member
milestogo

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