Can i combine these 2 formulas into 1? MAX IF

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
788
Office Version
  1. 365
Platform
  1. Windows
Hi,

i have the 2 formulas which work

G2
Code:
{=MAX(IF($A$2:$A$20000=A2,$G$2:$G$20000,0))}
gets max value of column A data

H2
Code:
=IF(G2=O2,1,0)
checks to see if value in G2 is highest, if so output 1

Im sure i can merge these somehow

thanks in advance
 
Last edited:
is there a reason why it doesnt let me fill down this array formula with vba ?

See if this works
Code:
lr = Cells(Rows.Count, "L").End(xlUp).Row
[COLOR=#0000ff]Range("x2")[/COLOR].FormulaArray = "=(RC7=MAX(IF(R2C1:R20000C1=RC1,R2C7:R20000C7)))+0"
Range("x2:x" & lr).FillDown

In VBA to enter an array formula in multiple cells it's a little bit tricky - you must enter the formula only in the first cell and then copy/paste or fill it down.
Take a look at
https://colinlegg.wordpress.com/2012/05/23/working-with-range-formulaarray-in-vba/

M.
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
See if this works
Code:
lr = Cells(Rows.Count, "L").End(xlUp).Row
[COLOR=#0000ff]Range("x2")[/COLOR].FormulaArray = "=(RC7=MAX(IF(R2C1:R20000C1=RC1,R2C7:R20000C7)))+0"
Range("x2:x" & lr).FillDown

so each colour should only have one occurance of 1 in the H Column

In VBA to enter an array formula in multiple cells it's a little bit tricky - you must enter the formula only in the first cell and then copy/paste or fill it down.
Take a look at
https://colinlegg.wordpress.com/2012/05/23/working-with-range-formulaarray-in-vba/

M.

thankyou i got it working

now with this formula

Rich (BB code):
=($G2=MAX(IF($A$2:$A$20000=$A2,$G$2:$G$20000)))+0

ABCDEFGh
red000002160
red000002541
blue000005711
blue000005711
blue00000440
yellow00000331
green000004800
green00000480
green000005141
black00000810
black00000370
black000001341
white000002361
white00000390

see for blue, there is duplicate max values
is it possible to just output a "1" for just one record of blue if that makes sense ?
[/FONT]
 
Last edited:
Upvote 0
thankyou i got it working

now with this formula

Code:
=($G2=MAX(IF($A$2:$A$20000=$A2,$G$2:$G$20000)))+0

ABCDEFGh
red000002160
red000002541
blue000005711
blue000005711
blue00000440
yellow00000331
green000004800
green00000480
green000005141
black00000810
black00000370
black000001341
white000002361
white00000390

<tbody>
</tbody>

see for blue, there is duplicate max values
is it possible to just output a "1" for just one record of blue if that makes sense ?
[/FONT]

Control+shift+enter, not just enter:

=IF(COUNTIFS($A$2:$A2,$A2,$G$2:$G2,$G2)=1,($G2=MAX(IF($A$2:$A$20000=$A2,$G$2:$G$20000)))+0,"")
 
Upvote 0

Forum statistics

Threads
1,223,708
Messages
6,174,006
Members
452,542
Latest member
Bricklin

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