Max and Min VBA Statement
You mean as a macro to run.
Option Explicit
Sub CalculateMinAndMax()
Dim rng As Range, l As Long
Dim lMin As Long, lMax As Long
Dim v As Variant, i As Long
Dim s As String
Set rng = Range("A1", Cells(Rows.Count, 1).End(xlUp))
v = rng.Value
lMin = 1000000
lMax = -1000000
For i = LBound(v) To UBound(v)
s = v(i, 1)
If UCase(Right(s, 1)) = "A" Then
l = Val(s)
If lMin l Then
lMin = l
End If
If lMax < l Then
lMax = l
End If
End If
Next
Range("K1").Value = lMin
Range("L1").Value = lMax
End Sub
--
Regards,
Tom Ogilvy
"maperalia" wrote in message
...
I have the following formulas setup in the cells:
K10=IF(A1=0,"",MIN(IF(RIGHT($A$1:$A$30000)="A",--(LEFT($A$1:$A$30000,LEN($A$
1:$A$30000)-1)))))
and
L10=IF(A1=0,"",MAX(IF(RIGHT($A$1:$A$30000)="A",--(LEFT($A$1:$A$30000,LEN($A$
1:$A$30000)-1)))))
It is working Ok!, however, takes too much time to run it because I am
using
30,000 rows.
I wonder if there is any way if you can help me to get the statement to
make
it run as a VBA and make it until last row is empty because as you see in
my
formula I am calculating for 30,000 rows and in addition of the time is
been
taking to run it, I am concern if my data exceed this number and I have to
change the formula all the time.
Thanks in advance.
Maperalia
|