OK.. I tested the use of the hlookup
(I'm usually using vlookup, so I don't have much practice)
I put the column numbers in row 16.
This formula finds the maximum value in the row and returns the
column number from row 16.
=HLOOKUP(MAX(B1:K1),B1:$K$16,ROWS(B1:$K$16),FALSE)

if you want the result to read something like:

Column 1, MAX = 937
then you can use:

="Column " & HLOOKUP(MAX(B1:K1),B1:$K$16,ROWS(B1:$K$16),FALSE) & ", Max= " & 
MAX(B1:K1)

had to make a minor adjustment to the macro:


Sub maxtest()
    Dim R, C, maxval, maxcol
    For R = 1 To 15
    maxval = 0
    maxcol = ""
        For C = 2 To 11
          If (Cells(R, C).Value > maxval) Then
            maxval = Cells(R, C).Value
            maxcol = C
          End If
        Next C
        Cells(R, 1) = "Column " & maxcol & ", Max= " & maxval
     Next R
End Sub

hope this helps (hth)

Paul



________________________________
From: Paul Schreiner <schreiner_p...@att.net>
To: excel-macros@googlegroups.com
Sent: Wed, December 9, 2009 9:25:02 AM
Subject: Re: $$Excel-Macros$$ Getting the maximum along rows and place they 
occured


Are you SURE you want a macro?
the =max function could return the maximum value in the row.
I'll have to test it, but the =hlookup function
should be able to return the column heading.
if you want the column NUMBER, then you could put the
numbers in the first row of the matrix...

if you want a macro..
Assuming the rows are 1-15 and columns are in 2-11
and you want the maximum value and column number in column 1...

sub maxtest()
    dim R, C, maxval, maxcol
    maxval= 0
    maxcol = ""
    for R = 1 to 15
        for C = 2 to 11
          if (cells(R,C).value > maxval) then
            maxval = cells(R,C).value
            maxcol = C
          end if
        next C
        cells(R,1) = maxval & ":" & maxcol
     next R
end sub

Paul



________________________________
From: Mammo <debebe...@gmail.com>
To: MS EXCEL AND VBA MACROS <excel-macros@googlegroups.com>
Sent: Tue, December 8, 2009 2:14:16 PM
Subject: $$Excel-Macros$$ Getting the maximum along rows and place they occured

I have a 15 by 10 matrix defined as an array.

For each 15 row, I would like to get the maximum value and te column
number at which this maximum value occurs.

How can I make a vba macro for this?

I appreciate your help.

M.

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com


To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain  @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,500 subscribers worldwide and receive many nice notes about the 
learning and support from the group. Our goal is to have 10,000 subscribers by 
the end of 2009. Let friends and co-workers know they can subscribe to group at 
http://groups.google.com/group/excel-macros/subscribe
-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com

 
To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!
 
We reach over 6,500 subscribers worldwide and receive many nice notes about the 
learning and support from the group. Our goal is to have 10,000 subscribers by 
the end of 2009. Let friends and co-workers know they can subscribe to group at 
http://groups.google.com/group/excel-macros/subscribe

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain  @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,500 subscribers worldwide and receive many nice notes about the 
learning and support from the group. Our goal is to have 10,000 subscribers by 
the end of 2009. Let friends and co-workers know they can subscribe to group at 
http://groups.google.com/group/excel-macros/subscribe

Reply via email to