Finding the Max & Min Values regarding to 2 Criterias

uygaroz

New Member
Joined
Feb 6, 2017
Messages
6
Good Day to all
I am trying to replace below formulas with a macro code.

=Min(if($C$7:$C$14940=$N7;if($D$7:$D$14940=M$7;$F$7:$F$11940)))
=Max(if($C$7:$C$14940=$N7;if($D$7:$D$14940=$M7;$F$7:$F$14940)))


I have 2 criterias
Criteria 1 : Plate Number like (PN AU 2095)
Criteria 2 : Period like (2018/01)

I try to find max or min values from Column (F7:to last Row) with multiple criteria.

Column (D7:to last row)= Plate Numbers
Column (C7:to last row)= Periods
Column (F7:to last row)= Kilometers (where the code must get the max or min "Km" regarding to these 2 criteria.)

Thanks for any help from now.


I am not allowed to load file to forum yet.
That is why I had load my file to link below.

Excel file link : [FONT=source_sans_proregular]https://mega.nz/#!BssiGRaa[/FONT][FONT=source_sans_proregular]!iNznlQslb_7u0WK0bAm20dHMnNmx9503AcP56YIV5YA[/FONT]


Note : By "recording macro" I can get this code. But I am not looking for something like this.

Range("Q9").Select
Selection.FormulaArray = _
"=MIN(IF(R7C3:R14940C3=R[-1]C14,IF(R7C4:R14940C4=R3C[-4],R7C6:R11940C6)))"
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Yes I have already did it with pivot table.
But as I mentioned, I have solution with formula too.

My aim is not find a solution, it is to convert the formulas to macro codes.
 
Upvote 0
Table No 1 :
ABCDEFGHI
NoDatePeriodPlate NoCityKmLitreLitre PriceAmount
7126.01.20182018/01PN AU 2095SARAY400.00050,623,39171,58
8222.01.20182018/01PN AU 2095SARAY399.50065,153,39220,83
9316.01.20182018/01PN AU 2095SARAY399.25050,023,33166,62
10411.01.20182018/01PN AU 2095SARAY399.00069,333,33230,95
11520.12.20172017/12PN HB 84PNADANA532.460621,353,392.108,62
12614.12.20172017/12PN HB 84PNSARAY527.400336,613,391.142,32

<tbody>
</tbody>


Table No 2 :

MNOPQR
Plate NumberPeriodTotal LiterTotal
Amount
Min KmMax Km
7PN AU 20952018/01235,12 Lt789,99399.000400.000
8PN AU 20952017/12217,20 Lt732,76370.569375.000
9PN AU 20952017/11274,44 Lt892,53368.000369.500

<tbody>
</tbody>


Steve hi again.
I have found our how I can add table here.
As you see I have table 1 where the data is located.


In Table 2
Using Max if / Min if formulas with 2 criteria (Plate number and Period) I am finding the max or/and min km from table one.

So what I need is
instead of using formulas and pivot table (where I can get the correct results)
want to replace my formulas with macro code.

Cell Q7 Formula= {
=Min(if($C$7:$C$14940=$N7;if($D$7:$D$14940=M$7;$F$7:$F$11940)))}
Cell R
7 Formula = {=Max(if($C$7:$C$14940=$N7;if($D$7:$D$14940=$M7;$F$7:$F$14940)))}

Formulas has to activated with Ctrl+shift + Enter
Hope it is clear.
Thanks
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,942
Members
449,094
Latest member
teemeren

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