Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Finding Location of Maximum Value in 2D Array


Gary''s Student wrote:
Hi Major:

Sub findmax()
Dim r As Range
Set r = Selection
v = r.Cells(1, 1).Value
For Each r In Selection
If r.Value v Then
v = r.Value
s = r.Address
End If
Next
MsgBox ("maximum value " & v & " found in cell " & s)
End Sub

This can easily be converted into a function as well.
--
Gary's Student


If the largest value is in the first cell, then "s" will be undefined. Need
to preset it to s=r.Cells(1,1).Address outside the loop. Also, if there are
multiple cells each with the largest values, the subroutine will only
identify the first one encountered.
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
How to know location of cell found with MIN/MAX? Dallman Ross Excel Discussion (Misc queries) 10 October 19th 06 04:57 AM
Finding a maximum number...with an exception cubsfan Excel Discussion (Misc queries) 1 April 7th 06 06:48 PM
Finding Maximum value while excluding some values tx12345 Excel Worksheet Functions 15 February 4th 06 08:59 PM
Question to Bob Phillips (or whoever...) vezerid Excel Worksheet Functions 5 December 11th 05 11:44 AM
Stock Location Sorting Problem mark1caroline Excel Discussion (Misc queries) 3 July 13th 05 03:53 PM


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