Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Identifying the largest number

I am in need of some help regarding the creation of a simple MAX calculation
in my code.

The data is something like the following:

Col I Col J Col K Col L
12 4 7 19

How would I write a line of code that will identify that within this array
Column L has the largest figure?

Many thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Identifying the largest number

Hello Phil

Msgbox "Max value is in " & _
Evaluate("=ADDRESS(1,MATCH(MAX(I1:L1),I1:L1,0))")

HTH
Cordially
Pascal


"Phil" a écrit dans le message de news:
...
I am in need of some help regarding the creation of a simple MAX
calculation
in my code.

The data is something like the following:

Col I Col J Col K Col L
12 4 7 19

How would I write a line of code that will identify that within this array
Column L has the largest figure?

Many thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Identifying the largest number

A function would do it, assuming your data are in the named range myRange:-

Function MaxAddress(myRange)
MaxNum = Application.Max(myRange)
For Each Cell In myRange
If Cell = MaxNum Then
MaxAddress = Cell.Address
Exit For
End If
Next Cell

call the funxtion with =maxaddress(myrange) typed in any cell

Mike
End Function

"Phil" wrote:

I am in need of some help regarding the creation of a simple MAX calculation
in my code.

The data is something like the following:

Col I Col J Col K Col L
12 4 7 19

How would I write a line of code that will identify that within this array
Column L has the largest figure?

Many thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Identifying the largest number

Ok, this should work better:
MsgBox "Max value is in " & _
Evaluate("=ADDRESS(ROW(A1),MATCH(MAX(1:1),1:1,0))" )

HTH
Cordially
Pascal

"papou" a écrit dans le message de news:
...
Hello Phil

Msgbox "Max value is in " & _
Evaluate("=ADDRESS(1,MATCH(MAX(I1:L1),I1:L1,0))")

HTH
Cordially
Pascal


"Phil" a écrit dans le message de news:
...
I am in need of some help regarding the creation of a simple MAX
calculation
in my code.

The data is something like the following:

Col I Col J Col K Col L
12 4 7 19

How would I write a line of code that will identify that within this
array
Column L has the largest figure?

Many thanks







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default Identifying the largest number

Hi Pascal

I think modifying your posting to
MsgBox "Max value is in " & _
Evaluate("=ADDRESS(1,MATCH(MAX(I1:L1),I1:L1,0)+col umn(I1)-1)")

will resolve the matter

--
Regards

Roger Govier


"papou" wrote in message
...
Phil
Forget my answer, it will not return the correct address.
I will have another look at it.

Cordially
Pascal

"papou" a écrit dans le message de news:
...
Hello Phil

Msgbox "Max value is in " & _
Evaluate("=ADDRESS(1,MATCH(MAX(I1:L1),I1:L1,0))")

HTH
Cordially
Pascal


"Phil" a écrit dans le message de
news:
...
I am in need of some help regarding the creation of a simple MAX
calculation
in my code.

The data is something like the following:

Col I Col J Col K Col L
12 4 7 19

How would I write a line of code that will identify that within this
array
Column L has the largest figure?

Many thanks







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Identifying the largest number

Hi Roger
Yes definitely ;-)

Cordially
Pascal

"Roger Govier" a écrit dans le message de
news: ...
Hi Pascal

I think modifying your posting to
MsgBox "Max value is in " & _
Evaluate("=ADDRESS(1,MATCH(MAX(I1:L1),I1:L1,0)+col umn(I1)-1)")

will resolve the matter

--
Regards

Roger Govier


"papou" wrote in message
...
Phil
Forget my answer, it will not return the correct address.
I will have another look at it.

Cordially
Pascal

"papou" a écrit dans le message de news:
...
Hello Phil

Msgbox "Max value is in " & _
Evaluate("=ADDRESS(1,MATCH(MAX(I1:L1),I1:L1,0))")

HTH
Cordially
Pascal


"Phil" a écrit dans le message de news:
...
I am in need of some help regarding the creation of a simple MAX
calculation
in my code.

The data is something like the following:

Col I Col J Col K Col L
12 4 7 19

How would I write a line of code that will identify that within this
array
Column L has the largest figure?

Many thanks








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default Identifying the largest number

Hi Pascal

Wouldn't that return the address of the highest value in row 1, even it
were outside the range that the OP wanted?

--
Regards

Roger Govier


"papou" wrote in message
...
Ok, this should work better:
MsgBox "Max value is in " & _
Evaluate("=ADDRESS(ROW(A1),MATCH(MAX(1:1),1:1,0))" )

HTH
Cordially
Pascal

"papou" a écrit dans le message de news:
...
Hello Phil

Msgbox "Max value is in " & _
Evaluate("=ADDRESS(1,MATCH(MAX(I1:L1),I1:L1,0))")

HTH
Cordially
Pascal


"Phil" a écrit dans le message de
news:
...
I am in need of some help regarding the creation of a simple MAX
calculation
in my code.

The data is something like the following:

Col I Col J Col K Col L
12 4 7 19

How would I write a line of code that will identify that within this
array
Column L has the largest figure?

Many thanks







  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Identifying the largest number

Good responses, but you don't really need a new function for this.
Assuming that the values are in row 2, you could place the following
formula in M2.
=ADDRESS(ROW(),COLUMN(INDEX(I2:L2,MATCH(MAX(I2:L2) ,I2:L2,0))))
That would return an absolute reference such as $L$2. You could then
use the Mid function to pull out the column letter.
=MID(ADDRESS(ROW(),COLUMN(INDEX(I2:L2,MATCH(MAX(I2 :L2),I2:L2,0)))),2,
(FIND("$",ADDRESS(ROW(),COLUMN(INDEX(I2:L2,MATCH(M AX(I2:L2),I2:L2,0)))),
2)-2))

Pretty complex formula, but it works.

HTH

Roger Govier wrote:
Hi Pascal

I think modifying your posting to
MsgBox "Max value is in " & _
Evaluate("=ADDRESS(1,MATCH(MAX(I1:L1),I1:L1,0)+col umn(I1)-1)")

will resolve the matter

--
Regards

Roger Govier


"papou" wrote in message
...
Phil
Forget my answer, it will not return the correct address.
I will have another look at it.

Cordially
Pascal

"papou" a écrit dans le message de news:
...
Hello Phil

Msgbox "Max value is in " & _
Evaluate("=ADDRESS(1,MATCH(MAX(I1:L1),I1:L1,0))")

HTH
Cordially
Pascal


"Phil" a écrit dans le message de
news:
...
I am in need of some help regarding the creation of a simple MAX
calculation
in my code.

The data is something like the following:

Col I Col J Col K Col L
12 4 7 19

How would I write a line of code that will identify that within this
array
Column L has the largest figure?

Many thanks







  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default Identifying the largest number

Hi

I hadn't noticed that the Op wanted just the column letter.
That being the case then
=SUBSTITUTE(ADDRESS(1,MATCH(MAX(I1:L1),I1:L1,0)+CO LUMN(I1)-1,4),"1","")

will achieve that in a shorter form

--
Regards

Roger Govier


"JW" wrote in message
oups.com...
Good responses, but you don't really need a new function for this.
Assuming that the values are in row 2, you could place the following
formula in M2.
=ADDRESS(ROW(),COLUMN(INDEX(I2:L2,MATCH(MAX(I2:L2) ,I2:L2,0))))
That would return an absolute reference such as $L$2. You could then
use the Mid function to pull out the column letter.
=MID(ADDRESS(ROW(),COLUMN(INDEX(I2:L2,MATCH(MAX(I2 :L2),I2:L2,0)))),2,
(FIND("$",ADDRESS(ROW(),COLUMN(INDEX(I2:L2,MATCH(M AX(I2:L2),I2:L2,0)))),
2)-2))

Pretty complex formula, but it works.

HTH

Roger Govier wrote:
Hi Pascal

I think modifying your posting to
MsgBox "Max value is in " & _
Evaluate("=ADDRESS(1,MATCH(MAX(I1:L1),I1:L1,0)+col umn(I1)-1)")

will resolve the matter

--
Regards

Roger Govier


"papou" wrote in message
...
Phil
Forget my answer, it will not return the correct address.
I will have another look at it.

Cordially
Pascal

"papou" a écrit dans le message de news:
...
Hello Phil

Msgbox "Max value is in " & _
Evaluate("=ADDRESS(1,MATCH(MAX(I1:L1),I1:L1,0))")

HTH
Cordially
Pascal


"Phil" a écrit dans le message de
news:
...
I am in need of some help regarding the creation of a simple MAX
calculation
in my code.

The data is something like the following:

Col I Col J Col K Col L
12 4 7 19

How would I write a line of code that will identify that within
this
array
Column L has the largest figure?

Many thanks






  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Identifying the largest number

Many Thanks for all of your suggestions. I think ultimately what I was trying
to do was too complicated for the needs of the workbook.

I have used some of what has been proposed but have also created a workround.

Thanks again for all of your help.

"Phil" wrote:

I am in need of some help regarding the creation of a simple MAX calculation
in my code.

The data is something like the following:

Col I Col J Col K Col L
12 4 7 19

How would I write a line of code that will identify that within this array
Column L has the largest figure?

Many thanks

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
Largest number in column peteewheat11 Excel Discussion (Misc queries) 4 September 7th 09 05:18 PM
Largest number 2 MAX Excel Worksheet Functions 3 April 29th 09 05:50 PM
Largest number MAX Excel Worksheet Functions 4 April 29th 09 05:20 PM
highlight largest number in a row snmcpa Excel Worksheet Functions 2 July 17th 06 07:50 PM
Largest number in a column eyecalibrate[_8_] Excel Programming 1 April 26th 06 02:36 PM


All times are GMT +1. The time now is 12:56 PM.

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

About Us

"It's about Microsoft Excel"