View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
INTP56 INTP56 is offline
external usenet poster
 
Posts: 66
Default Finding a floating point value

I have a data file where one column has a section name and later I have a
column that is a rolling average of another column.

I have a routine that finds the range of that column based on section name
and assigns it to a variable, rngTarget. I've validated this part of the code
is selecting the correct range

Now, in a loop for each section, I do the following:

dblAveMinValue = Application.WorksheetFunction.Min(rngTarget)
Set rngTargetMinCell = rngTarget.Find( _
What:=dblAveMinValue, LookAt:=xlWhole, LookIn:= xlValues)
If Not rngTargetMinCell is Nothing Then
With rngTargetMinCell.Borders
.LineStyle = xlContinuous
.Weight = xlThick
End With
Else
MsgBox "Could Not find cell with value " & cstr(dblAveMinValue)
End If

There is always the right value in dblAveMinValue, but .Find can't find it.
I tried using varAveMinValue (Declared as Variant) but it makes no
difference. I realize there are issues with searching for Floating point
numbers, but I was hoping that searching for the value I just found would
work. :(

I'm wondering if how Excel stores the data in the worksheet is different
than how the value is represented as a double. Of course, I can pull the
range into a variant, iterate throught the range myself looking for the min
value, and save the index to translate it back to the sheet.

Is this the best way to accomplish this task?

Bob