Paging Toppers for the macro
Try this (assuming I understood the requirements:
Sub sumitx()
Dim rnga As Range, rngb As Range
Dim r1 As Long, r2 As Long, sr As Long, lastrow As Long, rmax As Long
Dim tot As Double, maxb As Double
maxlimit = Cells(9, "K") ' Store max limit
For n = 8 To 9 ' Loop through columns H & I
Cells(10, n + 3).Resize(2000, 1).ClearContents ' Clear columns K & L
lastrow = Cells(Rows.Count, n).End(xlUp).Row
sr = 9
Do
Do
sr = sr + 1
Loop Until Cells(sr, n) < 0
r1 = sr
maxb = 0
Do
If Abs(Cells(sr, n)) Abs(maxb) Then
maxb = Cells(sr, n)
End If
sr = sr + 1
Loop Until Cells(sr, n) = 0
r2 = sr - 1
If Abs(maxb) = maxlimit Then ' Check if max exceeds threshold ......
Set rnga = Range(Cells(r1, "G"), Cells(r2, "G"))
Set rngb = Range(Cells(r1, n), Cells(r2, n))
tot = Application.Sum(rnga)
rmax = Application.Match(maxb, rngb, 0) + r1 - 1
Cells(rmax, n + 3) = tot
End If
Loop Until sr = lastrow
Next n
End Sub
"driller" wrote:
from previous post "how to sum this easily"...
please help me with the macro to adjust with the following
"Ineed to have some heading space on the top of myfile"....
1. the data range to be summed is G10:G2000 (previously Column A)
2. the negative ref. values - criteria range is on H10:H2000 (previously
Column B)
3. the positive ref. values + criteria range is on I10:I2000 (also
previously on Column B).
4. the sum result range (for the negative ref. criteria) is on K10:K2000
5. the sum result range (for the positive ref. criteria) is on L10:L2000
6. I place in Cell K9 a certain value for a sumif range criteria.....e.g. if
i place there a value of 10, then it means i only need to sum the multi-range
in G2:G2000 if the Absolute MAX ref. Value on column H & I is equal or
greater than cell K9...
i know this will do the trick for me to have an instant charting of the
summed results on multi-range...
THANKS A LOT...
regards
--
*****
birds of the same feather flock together..
|