Need proper formula for max

jackt05

Board Regular
Joined
Feb 1, 2009
Messages
194
Dear All Hi,


LocationKMNeeded Output
CHIKHALI7070
KARVE NAGAR440
DHANKWADI380
BHOSARI6060
KASARWADI480
NARHE500
AMBEGAON PATHAR480
KATRAJ KONDHWA ROAD360
LOHEGAON420
NIGADI7373
DHOLE PATIL ROAD240
DHANKWADI380
FURSUNGI200
CHINCHWAD GAON6868
THERGAON640
BALEWADI6060
NARHE500
NDA500
MUNDHWA ROAD120

<tbody>
</tbody>


I have the above table

In column 3. I want the expected results shown already shown.

I want to use this formula =IF(MAX(B2:B4)=B2,MAX(B2:B4),"") This is to be used only for rows above blank rows.
but the cell ranges changes gradually and for 2nd row the formula range becomes B3:B5
Which results in Wrong answers.
Please if anyone can give proper formula so that the range is always between the blank rows.

Hope I am able to explain the problem.

Thank in Advance
Jack
 
In that case use
Code:
Sub jackt05()
   Dim Rng As Range
   For Each Rng In Range("[COLOR=#ff0000]J:J[/COLOR]").SpecialCells(xlConstants).Areas
      Rng.Offset(, 1).FormulaR1C1 = "=IF(MAX(" & Rng.Address(1, 1, xlR1C1) & ")=rc[-1],MAX(" & Rng.Address(1, 1, xlR1C1) & "),"""")"
   Next Rng
End Sub
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi Fluff

Somethings not working the formula comes only in the 1st row that also half as this =IF(MAX($J$1)=J1,MAX($J$1),"")
 
Upvote 0
Hi Fluff,

Sorry it is working perfectly as expected you saved a lot of work.

First it did not work because column J contained a formula which after removing it worked.

Thanks for your valuable help.

Jack


Marked as Complete
 
Last edited:
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
If you are still interested in a direct formula solution, here is an array-entered** formula that should work (put it in cell K2 and copy down)...

=IF(J2="","",IF(J2=MAX(INDEX(J:J,MAX(IF(J$2:J2="",ROW(J$2:J2)))+1):INDEX(J:J,MIN(IF(J2:J$25="",ROW(J2:J$25)))-1)),J2,0))

**Commit this formula using CTRL+SHIFT+ENTER and not just Enter by itself.

NOTE: The red highlight cell reference must be one (or more cells) below the last data cell in Column J.
 
Last edited:
Upvote 0
Thanks Rick,

This also works exactly as required.
I was searching the same thing earlier.

Jack
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,267
Members
449,075
Latest member
staticfluids

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