Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
AG
 
Posts: n/a
Default Cell value using Max

Looking for a formula that will give the value of the leftmost cell (column
A), 1 row up from a cell containing the maximum value in a table of values
contained in the range $B$5:$AF$97, named rng.

I can find the address of the max value via the array formula:

=CELL("Address",INDEX(rng,MATCH(TRUE,COUNTIF(OFFSE T(rng,ROW(rng)-CELL("Row",rng),0,1,),MAX(rng))0,0),MATCH(MAX(rng ),INDEX(rng,MATCH(TRUE,COUNTIF(OFFSET(rng,ROW(rng)-CELL("Row",rng),0,1,),MAX(rng))0,0),0),0)))

So if the max value happened to be in cell $W$57, how would I get the value
of cell $A$56?

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Kevin Vaughn
 
Posts: n/a
Default Cell value using Max

If the cell returning the address of $w$57 is in B2, try this formula:

=INDIRECT("a"&ROW(INDIRECT(B2))-1)

--
Kevin Vaughn


"AG" wrote:

Looking for a formula that will give the value of the leftmost cell (column
A), 1 row up from a cell containing the maximum value in a table of values
contained in the range $B$5:$AF$97, named rng.

I can find the address of the max value via the array formula:

=CELL("Address",INDEX(rng,MATCH(TRUE,COUNTIF(OFFSE T(rng,ROW(rng)-CELL("Row",rng),0,1,),MAX(rng))0,0),MATCH(MAX(rng ),INDEX(rng,MATCH(TRUE,COUNTIF(OFFSET(rng,ROW(rng)-CELL("Row",rng),0,1,),MAX(rng))0,0),0),0)))

So if the max value happened to be in cell $W$57, how would I get the value
of cell $A$56?

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
AG
 
Posts: n/a
Default Cell value using Max

This works for; nice & simple, too!

"AG" wrote:

Looking for a formula that will give the value of the leftmost cell (column
A), 1 row up from a cell containing the maximum value in a table of values
contained in the range $B$5:$AF$97, named rng.

I can find the address of the max value via the array formula:

=CELL("Address",INDEX(rng,MATCH(TRUE,COUNTIF(OFFSE T(rng,ROW(rng)-CELL("Row",rng),0,1,),MAX(rng))0,0),MATCH(MAX(rng ),INDEX(rng,MATCH(TRUE,COUNTIF(OFFSET(rng,ROW(rng)-CELL("Row",rng),0,1,),MAX(rng))0,0),0),0)))

So if the max value happened to be in cell $W$57, how would I get the value
of cell $A$56?

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
GaryE
 
Posts: n/a
Default Cell value using Max


Did you try to use the offset function? It looks like that might do
exactly what you want. Assuming that you did try or that it won't work
here is an alternative.

You can use the len() function to determine how many characters are in
the reference. Then use the right() function to grab the number off the
end of the reference (depending upon the lenght of the reference).
Subtract 1. Then use the & feature to merge the text "$A$" with that
value.

You need to know how long the reference is so that you chop off just
the number at the end of the reference.

In other words if the reference value is "$A$5" you just want the 5 at
the end. If the reference value is "$A$15" you want the 15 at the end
etc.

ok?


So lets assume that the cell A7 contains the value
$E$9

so in pseudo code that looks like this

if the length is 4
then print "$A$"
add the right most character to the end of that text string
after subtracting 1
&right(A7,1)-1
else print "Length is greater than 4"

Note that Len(A7) returns: 4
right(A7,1) returns:9
and that right(A7,1)-1 returns: 8

in excel it looks like this:
=if(len(A7)=4,"$A$"&right(A7,1)-1,"Length is greater than 4")

and it will return: $A$8

now if the length is 5 (the cell reference ends in two digits)

so lets say that cell A7 contains $E$14

if(len(A7)=5"$A$"&right(A7,1)-1,"Length is greater than 5"

will return $A$13

so put the second if statement in place of the text "Length is greater
than 4" of the first statement. And continue on until you have the max
number of rows in your worksheet taken care of.

Assuming that you have less than 1000 rows
use

IF(LEN(A7)=4,"$A$"&RIGHT(A7,1)-1,IF(LEN(A7)=5,"$A$"&RIGHT(A7,2)-1,"$A$"&RIGHT(A7,3)-1),"Error
the reference contains more than 999 rows")

is that clear as mud?

Any questions let me know!

(I'm doing this from work so I won't be able to get back to you until
Monday morning)

HTH,
Gary


--
GaryE
Posted from - http://www.officehelp.in

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
AG
 
Posts: n/a
Default Cell value using Max

Thanks for the reply Gary.
Your solution might work but see Kevin's reply for a simplier option.

"AG" wrote:

Looking for a formula that will give the value of the leftmost cell (column
A), 1 row up from a cell containing the maximum value in a table of values
contained in the range $B$5:$AF$97, named rng.

I can find the address of the max value via the array formula:

=CELL("Address",INDEX(rng,MATCH(TRUE,COUNTIF(OFFSE T(rng,ROW(rng)-CELL("Row",rng),0,1,),MAX(rng))0,0),MATCH(MAX(rng ),INDEX(rng,MATCH(TRUE,COUNTIF(OFFSET(rng,ROW(rng)-CELL("Row",rng),0,1,),MAX(rng))0,0),0),0)))

So if the max value happened to be in cell $W$57, how would I get the value
of cell $A$56?



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
GaryE
 
Posts: n/a
Default Cell value using Max


No Problem. Glad I could help (kind of :-).

FWIW the solution I posted will work -- I tested it thoroughly :-)

Gary


AG Wrote:
Thanks for the reply Gary.
Your solution might work but see Kevin's reply for a simplier option.

"AG" wrote:

Looking for a formula that will give the value of the leftmost cell

(column
A), 1 row up from a cell containing the maximum value in a table of

values
contained in the range $B$5:$AF$97, named rng.

I can find the address of the max value via the array formula:


=CELL("Address",INDEX(rng,MATCH(TRUE,COUNTIF(OFFSE T(rng,ROW(rng)-CELL("Row",rng),0,1,),MAX(rng))0,0),MATCH(MAX(rng ),INDEX(rng,MATCH(TRUE,COUNTIF(OFFSET(rng,ROW(rng)-CELL("Row",rng),0,1,),MAX(rng))0,0),0),0)))

So if the max value happened to be in cell $W$57, how would I get the

value
of cell $A$56?



--
GaryE
Posted from - http://www.officehelp.in

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
why a reference to an empty cell is not considered empty Nicoscot Excel Discussion (Misc queries) 10 March 10th 06 05:36 AM
Adding a row to worksheet does not update cell references in another. blausen Excel Worksheet Functions 5 February 25th 06 09:14 PM
Instead of a negative number, I'd like to show zero... Dr. Darrell Excel Worksheet Functions 6 December 7th 05 08:21 PM
Cell color based upon cell value My View Excel Discussion (Misc queries) 11 July 6th 05 03:59 AM
cell color index comparison MINAL ZUNKE New Users to Excel 1 June 30th 05 07:11 AM


All times are GMT +1. The time now is 04:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"