#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default for loops

you don't really need a macro to do what you're describing. assuming your
potential max value is in column B this formula would return the max:

=MAX(B:B)

and assuming the max value cannot occur in the column more than once, this
would return the value to the left of it:

=INDIRECT(ADDRESS(MATCH(MAX(B:B),B:B,0),1))



"blazafan7" wrote:

I am trying to create a macro from scratch that can tell me what value is the
maximum value in a column of values and then what the value is in the cell to
the left of that max value. I thought a for loop would work for the max
value part but i dont know how to get it to do that last part. Any help
would be great, I am not good at programming.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default for loops

The below returns the values from ColA for the max value in ColB

MsgBox Range("A" & WorksheetFunction.Match( _
WorksheetFunction.Max(Range("B:B")), Range("B:B"), 0))

--
Jacob


"B Lynn B" wrote:

you don't really need a macro to do what you're describing. assuming your
potential max value is in column B this formula would return the max:

=MAX(B:B)

and assuming the max value cannot occur in the column more than once, this
would return the value to the left of it:

=INDIRECT(ADDRESS(MATCH(MAX(B:B),B:B,0),1))



"blazafan7" wrote:

I am trying to create a macro from scratch that can tell me what value is the
maximum value in a column of values and then what the value is in the cell to
the left of that max value. I thought a for loop would work for the max
value part but i dont know how to get it to do that last part. Any help
would be great, I am not good at programming.

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
Loops aqualibra Excel Programming 1 June 17th 09 06:33 PM
Do loops within Do loops Linking to specific cells in pivot table Excel Programming 4 April 14th 05 08:47 AM
Loops Hannes Excel Programming 3 December 29th 04 02:33 PM
for each loops adncmm1980[_3_] Excel Programming 1 October 4th 04 12:56 PM
Do Loops No Name Excel Programming 1 July 20th 04 04:47 PM


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