ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to Find the Max ? (https://www.excelbanter.com/excel-programming/438005-macro-find-max.html)

Anandh R

Macro to Find the Max ?
 
I need a macro to find a max value for range of cells and also the value of the cell adjacent to max cell.
i should input the range while running the macro.

kindly help me in this ...


Submitted via EggHeadCafe - Software Developer Portal of Choice
EggheadCafe Stock Quote WebService
http://www.eggheadcafe.com/tutorials...k-quote-w.aspx

joel[_482_]

Macro to Find the Max ?
 

You can use the worksheet function max and then search for the value
using Find like this


Set MyRange = Range("a1:a100")
MaxVal = worksheetfunction.max(MyRange)
Set C = MyRange.find(what:=MaxVal,lookin:=xlvalues,lookat: =xlwhole)
AdjacentValue = C.offset(0,1)


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=167026

Microsoft Office Help


Peter T

Macro to Find the Max ?
 
=INDEX(B1:B100,MATCH(MAX(A1:A100),A1:A100,0),1)

where the range you want to search Max is A1:A100 and you want to return the
cell in B1:B100.

Regards,
Peter T

<Anandh R wrote in message ...
I need a macro to find a max value for range of cells and also the value of
the cell adjacent to max cell.
i should input the range while running the macro.

kindly help me in this ...


Submitted via EggHeadCafe - Software Developer Portal of Choice
EggheadCafe Stock Quote WebService
http://www.eggheadcafe.com/tutorials...k-quote-w.aspx





All times are GMT +1. The time now is 09:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com