Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
mr_espresso
 
Posts: n/a
Default Function to return # of column with min value in selected rows

Hi folks. For the sample data below, columns A €“ C contain survey response
data: 3, 6 and 9. I'm looking for advice on writing a function for column D
that would look at columns A €“ C and return the # of the column containing
the min value (e.g. A in this example). Thank you in advance!

A B C D
3 6 9 A
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ardus Petus
 
Posts: n/a
Default Function to return # of column with min value in selected rows

Try this:
=ADDRESS(ROW(),COLUMN(A1)+MATCH(MIN(A1:C1),A1:C1,0 )-1,4)

It wille return a cell address, like: A1

HTH
--
AP

"mr_espresso" a écrit dans le message
de news: ...
Hi folks. For the sample data below, columns A - C contain survey response
data: 3, 6 and 9. I'm looking for advice on writing a function for column
D
that would look at columns A - C and return the # of the column containing
the min value (e.g. A in this example). Thank you in advance!

A B C D
3 6 9 A



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
mr_espresso
 
Posts: n/a
Default Function to return # of column with min value in selected rows

Excellent! Thank you for that fast reply.

One follow-up question. Is it possible to remove the row number from the
result so only the column number is returned (e.g. A instead of A1)? This is
important because each column number is going to be relabeled in my stats
software and I'd like to avoid relabeling 1000s of cell addresses!

Thanks again

"Ardus Petus" wrote:

Try this:
=ADDRESS(ROW(),COLUMN(A1)+MATCH(MIN(A1:C1),A1:C1,0 )-1,4)

It wille return a cell address, like: A1

HTH
--
AP

"mr_espresso" a écrit dans le message
de news: ...
Hi folks. For the sample data below, columns A - C contain survey response
data: 3, 6 and 9. I'm looking for advice on writing a function for column
D
that would look at columns A - C and return the # of the column containing
the min value (e.g. A in this example). Thank you in advance!

A B C D
3 6 9 A




  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Tushar Mehta
 
Posts: n/a
Default Function to return # of column with min value in selected rows

If your data are in row 2, use the untested =MATCH(MIN(A2:C2),A2:C2,0).
This will return 1 for the 1st column, 2 for the 2nd, etc.

To convert that to the column letter, and as long as the result is in
the first 26 columns, use =CHAR(64+{above formula here w/o the = sign})

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Multi-disciplinary business expertise
+ Technology skills
= Optimal solution to your business problem
Recipient Microsoft MVP award 2000-2005

In article ,
says...
Hi folks. For the sample data below, columns A ¤=3F C contain survey response
data: 3, 6 and 9. I'm looking for advice on writing a function for columnD
that would look at columns A ¤=3F C and return the # of the columncontaining
the min value (e.g. A in this example). Thank you in advance!

A B C D
3 6 9 A

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gord Dibben
 
Posts: n/a
Default Function to return # of column with min value in selected rows

If you add this UDF to your workbook, you can return the column letter directly
up to IV

Function GetColLet(ColNumber As Integer) As String
GetColLet = Left(Cells(1, ColNumber).Address(False, False), _
1 - (ColNumber 26))
End Function

=getcollet(MATCH(MIN(2:2),2:2,0))


Gord Dibben MS Excel MVP


On Fri, 23 Jun 2006 09:18:31 -0400, Tushar Mehta
<tm_200310@tushar_hyphen_mehta_dot_see_oh_em wrote:

f your data are in row 2, use the untested =MATCH(MIN(A2:C2),A2:C2,0).
This will return 1 for the 1st column, 2 for the 2nd, etc.

To convert that to the column letter, and as long as the result is in
the first 26 columns, use =CHAR(64+{above formula here w/o the = sign})

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Multi-disciplinary business expertise
+ Technology skills
= Optimal solution to your business problem
Recipient Microsoft MVP award 2000-2005

In article ,
says...
Hi folks. For the sample data below, columns A €=3F C contain survey response
data: 3, 6 and 9. I'm looking for advice on writing a function for column D
that would look at columns A €=3F C and return the # of the column containing
the min value (e.g. A in this example). Thank you in advance!

A B C D
3 6 9 A


  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Tushar Mehta
 
Posts: n/a
Default Function to return # of column with min value in selected rows

Hi Gord,

The proposed UDF has two limitations. First, it requires an active
worksheet. Second, it wouldn't work with 2007.

The version below should work from 97 (assuming ConvertFormula was
available then) to 2007. Of course, I only have 2003 on the computer I
am currently using.

Option Explicit

Function ColumnChar(ColNumber As Integer) As String
Dim Temp As String
Temp = Application.ConvertFormula( _
"=R1C" & ColNumber, xlR1C1, xlA1, True)
ColumnChar = Mid(Temp, 3, _
Application.WorksheetFunction.Find("$", Temp, 3) - 3)
End Function
Sub testIt()
MsgBox ColumnChar(256)

End Sub

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Multi-disciplinary business expertise
+ Technology skills
= Optimal solution to your business problem
Recipient Microsoft MVP award 2000-2005

In article , Gord Dibben
<gorddibbATshawDOTca says...
If you add this UDF to your workbook, you can return the column letter directly
up to IV

Function GetColLet(ColNumber As Integer) As String
GetColLet = Left(Cells(1, ColNumber).Address(False, False), _
1 - (ColNumber 26))
End Function

=getcollet(MATCH(MIN(2:2),2:2,0))


Gord Dibben MS Excel MVP


On Fri, 23 Jun 2006 09:18:31 -0400, Tushar Mehta
<tm_200310@tushar_hyphen_mehta_dot_see_oh_em wrote:

f your data are in row 2, use the untested =MATCH(MIN(A2:C2),A2:C2,0).
This will return 1 for the 1st column, 2 for the 2nd, etc.

To convert that to the column letter, and as long as the result is in
the first 26 columns, use =CHAR(64+{above formula here w/o the = sign})

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Multi-disciplinary business expertise
+ Technology skills
= Optimal solution to your business problem
Recipient Microsoft MVP award 2000-2005

In article ,
says...
Hi folks. For the sample data below, columns A ?=3F C contain survey response
data: 3, 6 and 9. I'm looking for advice on writing a function for column D
that would look at columns A ?=3F C and return the # of the column containing
the min value (e.g. A in this example). Thank you in advance!

A B C D
3 6 9 A



  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gord Dibben
 
Posts: n/a
Default Function to return # of column with min value in selected rows

Thanks for the update Tushar.

I have gotten rid of my partition with Excel 97 so can't test anymore in that
version.


Gord

On Sat, 24 Jun 2006 14:14:34 -0400, Tushar Mehta
<tm_200310@tushar_hyphen_mehta_dot_see_oh_em wrote:

Hi Gord,

The proposed UDF has two limitations. First, it requires an active
worksheet. Second, it wouldn't work with 2007.

The version below should work from 97 (assuming ConvertFormula was
available then) to 2007. Of course, I only have 2003 on the computer I
am currently using.

Option Explicit

Function ColumnChar(ColNumber As Integer) As String
Dim Temp As String
Temp = Application.ConvertFormula( _
"=R1C" & ColNumber, xlR1C1, xlA1, True)
ColumnChar = Mid(Temp, 3, _
Application.WorksheetFunction.Find("$", Temp, 3) - 3)
End Function
Sub testIt()
MsgBox ColumnChar(256)

End Sub


Gord Dibben MS Excel MVP


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
Custom functions calculating time arguments Help Desperate Bill_De Excel Worksheet Functions 12 April 25th 06 02:22 AM
VLookUp function to return multiple rows sebastian stephenson Excel Worksheet Functions 7 April 20th 06 06:25 PM
Conditional Format as a MACRO Gunjani Excel Worksheet Functions 3 March 29th 06 05:22 PM
Function to return last entry in a column series? Tory Excel Worksheet Functions 2 November 7th 05 03:16 PM
return the column reference number of a function result Mahendhra Excel Discussion (Misc queries) 2 May 16th 05 12:46 PM


All times are GMT +1. The time now is 08:16 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"