Can i combine these 2 formulas into 1? MAX IF

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
785
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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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,215,930
Messages
6,127,752
Members
449,402
Latest member
jvivo3

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