Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
PROBLEM FINDING MINIMUM
Minval = Application.WorksheetFunction.Min(Range(Cells(1, 6), Cells(1, 8)))
CHEAPCOL% = Rows(1).Find(Minval, Cells(1, 5), LookIn:=xlFormulas).Column column 6 7 8 where row 1 reads 12.35 12.30 12.53 code returns 12.3 as the minimum value (correct) But CHEAPCOL% is returned as column 6 (wrong) How can this be resolved? Thanks Sunil |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
PROBLEM FINDING MINIMUM
Your code worked ok for me in light testing, but I'd limit my range and just
check in values: Option Explicit Sub testme() Dim minVal As Double Dim CheapCell As Range Dim CheapCol As Long With ActiveSheet With .Range(.Cells(1, 6), .Cells(1, 8)) minVal = Application.Min(.Cells) Set CheapCell = .Find(what:=minVal, after:=.Cells(.Cells.Count), _ LookIn:=xlValues, lookat:=xlWhole) If CheapCell Is Nothing Then CheapCol = 0 Else CheapCol = CheapCell.Column End If End With MsgBox CheapCol End With End Sub SUNIL PATEL wrote: Minval = Application.WorksheetFunction.Min(Range(Cells(1, 6), Cells(1, 8))) CHEAPCOL% = Rows(1).Find(Minval, Cells(1, 5), LookIn:=xlFormulas).Column column 6 7 8 where row 1 reads 12.35 12.30 12.53 code returns 12.3 as the minimum value (correct) But CHEAPCOL% is returned as column 6 (wrong) How can this be resolved? Thanks Sunil -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
PROBLEM FINDING MINIMUM
If you change your code to
CHEAPCOL% = Rows(1).Find(Minval, Cells(1, 6), LookIn:=xlFormulas).Column it will return column 7 -----Original Message----- Minval = Application.WorksheetFunction.Min(Range(Cells(1, 6), Cells(1, 8))) CHEAPCOL% = Rows(1).Find(Minval, Cells(1, 5), LookIn:=xlFormulas).Column column 6 7 8 where row 1 reads 12.35 12.30 12.53 code returns 12.3 as the minimum value (correct) But CHEAPCOL% is returned as column 6 (wrong) How can this be resolved? Thanks Sunil . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
finding minimum value excluding zero | Excel Discussion (Misc queries) | |||
Finding Minimum Value in series, excluding zero values | Excel Worksheet Functions | |||
Finding a maximum/minimum date in 2006 | Excel Discussion (Misc queries) | |||
Finding a minimum value and selecting the cell containing this val | Excel Worksheet Functions | |||
Finding minimum value across selected rows of an array | Excel Worksheet Functions |