View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tim Rush Tim Rush is offline
external usenet poster
 
Posts: 27
Default Max/Min for variable length columns

That did it... It make sense too (go figure), however, I did nodify the last
2 lines to
Cells(i + 1, Selection.Column).Value = minValue which keeps it in the same
column.

"Gordon Rainsford" wrote:

Sub maxMinValues()

Dim i As Long, bottomRow As Long
Dim maxValue As Double, minValue As Double

bottomRow = Cells(65536, Selection.Column).End(xlUp).Row

maxValue = Cells(9, Selection.Column).Value
For i = 9 To bottomRow
If Cells(i, Selection.Column).Value maxValue Then
maxValue = Cells(i, Selection.Column).Value
End If
Next i
Cells(i, Selection.Column).Value = maxValue
Cells(i, Selection.Column - 1).Value = "Maximum Value"

minValue = Cells(9, Selection.Column).Value
For i = 9 To bottomRow
If Cells(i, Selection.Column).Value < minValue Then
minValue = Cells(i, Selection.Column).Value
End If
Next i
Cells(i + 1, 4).Value = minValue
Cells(i + 1, 3).Value = "Minimum Value"

End Sub

Select a cell in the relevant column and then run.

--
Gordon Rainsford

London UK


"Tim Rush" <Tim wrote:

I need to find the max value in a column of unknown length, (start point at
about row 9). Then place that value in same column in next (blank) row.

Then do the same for MIN (but now it is column length -1)

This should be easy, but its been beating me all day.
Thanks