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