View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Kamal[_4_] Kamal[_4_] is offline
external usenet poster
 
Posts: 4
Default Finding the largest value

Hi Bernie,

Thanks for helping hand. I tested with your macro for 12000 rows. It
took about 9 mins. For the whole 50000 rows, this iteration will take
more than 30 mins. Already we in our existing process are using about
2 hours to create these 50,000 rows. This new solution would add 30
more mins. If we find a solution to reduce the CPU time to 15 mins, I
can use that solution. Again thanks for your help.

Kamal

"Bernie Deitrick" <deitbe @ consumer dot org wrote in message ...
Kamal,

Copy the macro below, and paste it into a code module in your workbook.
Then run the macro PutMaxAvgValues.

HTH,
Bernie
MS Excel MVP

Option Explicit
Sub PutMaxAvgValues()
Dim myRows As Long
Dim myCol As Integer
Dim myMax As Double

For myRows = 1 To ActiveSheet.UsedRange.Rows.Count
myMax = Application.Min(Range(myRows & ":" & myRows))
For myCol = 1 To 246
myMax = Application.Max(myMax, Application.Sum( _
Cells(myRows, myCol).Resize(1, 5)))
Next myCol
Cells(myRows, 251).Value = myMax / 5
Application.StatusBar = "Now doing row " & myRows & _
" of " & ActiveSheet.UsedRange.Rows.Count
Next myRows
Application.StatusBar = False
End Sub





"Kamal" wrote in message
om...
Bernie,

I prefer writing VBA macros for this scenario. However, I don't know
how to write a VBA macro. If you could help me that would be very
greatful.

The requirment is.

Col 251 for every row = [Max(Sum(A1:E1),Sum(B1:F1),....Sum(246th
col:250th col))]/5

Thanks in advance for your help.

Kamal

"Bernie Deitrick" <deitbe @ consumer dot org wrote in message

...
Kamal,

No. There is no better way to do that. You're stuck iterating through

all
the possibilities.

I suggest using a VBA macro or function rather than formulas. If you

need
help writing it, let us know.

HTH,
Bernie
MS Excel MVP

"Kamal" wrote in message
om...
I have an excel sheet with 250 columns and 50,000 rows. My requirment
is to get the largest sum total of any 5 CONSECUTIVE columns and
divide that sum by 5. To get the largest value for any row I have to
do 246 iterations. To find the required value for all the rows it
would take lot of processing time. Is there any better way of doing
this?