Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
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
finding minimum value excluding zero bookman3 Excel Discussion (Misc queries) 6 January 31st 07 03:31 AM
Finding Minimum Value in series, excluding zero values [email protected] Excel Worksheet Functions 5 January 30th 07 08:21 PM
Finding a maximum/minimum date in 2006 megacata Excel Discussion (Misc queries) 5 January 4th 07 06:43 PM
Finding a minimum value and selecting the cell containing this val Kokomojo Excel Worksheet Functions 3 February 5th 06 09:33 PM
Finding minimum value across selected rows of an array Dazed and confused about min, max Excel Worksheet Functions 2 February 25th 05 11:11 PM


All times are GMT +1. The time now is 08:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"