LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default A new excel challenge

The following macro will do the job, or you could rewrite it as a user
defined function:

Sub FindMaxCol()
Const Alph As String = "ABCDFX" 'The column labels you gave
Dim MaxCol As Long 'The col with the highest value so far
Dim MaxVal As Long 'The highest value so far
Dim RowIndex As Long 'The row of the current cell
Dim ColIndex As Long 'The colimn of the current cell

For RowIndex = 2 To Range("A65536").End(xlUp).Row 'go from row 2 to
last row
MaxVal = 0 'Highest val found so far
MaxCol = 1 'Col of highest value
For ColIndex = 1 To 6 'Examine each cell in current row
If Cells(RowIndex, ColIndex) MaxVal Then
'Cell is max so far so save its value and col number
MaxVal = Cells(RowIndex, ColIndex)
MaxCol = ColIndex
End If
Next ColIndex 'Look at next col in this row
'Convert col number to col label & save it
Range("G" & RowIndex) = Mid(Alph, MaxCol, 1)
Next RowIndex 'Look at next row
End Sub



On Thu, 13 Oct 2005 13:20:05 -0400, Nick Danger
wrote:

Hi folks,

I've run into a situation where I'm not sure what to do with it.

I have seven columns: A B C D F X and POP

beneath the letter colums are totals which can be of values 0 through
11.

What I ultimately want to do is have a formula in the pop cell
corresponding to each row of data which finds the maximum value and
shows the column name corresponding to it.

Following is an example of what I'd like POP to reflect based on
sample data:

A B C D F X POP
2 0 0 7 2 0 D
3 2 0 2 4 0 F
6 3 2 0 0 0 A

etc...

If anyone can give me an idea of which route to follow I'd appreciate
it.

Regards

Ben/ND


 
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
Excel formula - Anyone up for a challenge? NEHicks Excel Discussion (Misc queries) 6 December 8th 09 11:47 AM
Excel 2002 Challenge fp944s2 Excel Discussion (Misc queries) 2 June 30th 07 01:14 PM
A challenge for an Excel Master... wahiggin Excel Discussion (Misc queries) 9 June 3rd 06 01:44 PM
A Challenge (Linking word and Excel) Mr M Walker[_2_] Excel Programming 1 July 25th 05 09:33 AM
Challenge...Excel Chart to Power Point calculus87[_5_] Excel Programming 1 July 3rd 04 06:02 PM


All times are GMT +1. The time now is 10:59 AM.

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"