Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi all I'm trying to get a macro to find and select cell that contains th maximum value of 3 selected cells. Say cells A1 to A3 contain 2.45, 3.36, 2.78 (these numbers can change) the macro currently looks like: Sub FindMax() Range("A1").Activate StartCell = ActiveCell.Offset(0, 0).Address EndCell = ActiveCell.Offset(0, 2).Address Range(StartCell, EndCell).Select Dim WorkRange As Range Set WorkRange = Selection MaxVal = Application.Max(WorkRange) On Error Resume Next Workrange.Find(What:=MaxVal, _ After:=Workrange.Range("A1"), _ LookIn:=xlValues, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False _ ).Select If Err < 0 Then MsgBox "Max value was not found: " & MaxVal End Sub The code seems to work well on some selections, and not on others. Sometimes there is a unique maximum of, say, 3.36 and it will say "Ma Value was not found: 3.36" !?!? Please, does anyone have any ideas on where I'm going wrong? Thanks for your time Nei -- Mcneiliu ----------------------------------------------------------------------- Mcneilius's Profile: http://www.excelforum.com/member.php...fo&userid=1377 View this thread: http://www.excelforum.com/showthread.php?threadid=46855 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using VBA to find a value and select a range | Excel Worksheet Functions | |||
select date range then find average of values in another cell | Excel Worksheet Functions | |||
find maximum | Excel Discussion (Misc queries) | |||
find which column has the maximum value | Excel Discussion (Misc queries) | |||
How to Select a relative range with Using "Find" and Offset() | Excel Discussion (Misc queries) |