LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default I want a special Sum function but I need help with that

JPB,

Enter the code below in to a codemodule, and use it like:

=SpSum(A1:A150,B1:B150,"V",30)

HTH,
Bernie
MS Excel MVP

Function SpSum(R1 As Range, _
R2 As Range, _
Ignore As String, _
Pop As Integer) As Double

Dim myRow As Long
Dim myCount As Integer

myCount = 0
SpSum = 0

For myRow = R2(R2.Cells.Count).Row To 1 Step -1
If R1(myRow).Value < Ignore Then
SpSum = SpSum + R2(myRow).Value
myCount = myCount + 1
If myCount = Pop Then Exit Function
End If
Next myRow

End Function



wrote in message
ups.com...
I made some metacode how it should look like but I need more VBA help

' CounterDay represents the columnnr where the calculation has to
happen. Starts on row 31 untill row 365
' CounterV is the counter to count the number of V's he finds (it
stops counting when CounterN has reached 30
' CounterN Is Increased by 1 when the cell A(DAY-1-CounterV) is equal
to the Value "V"

CounterDay = 31

IF A(DAY-1-CounterV) = V
Then CounterV = CounterV+1
Else CounterN = CounterN+1
End If CounterN = 30

Sum=B(CounterDay-1):B(CounterDay-CounterN)
Put Sum in Cell C CounterDay
CounterDay + 1

End If CounterDay=365



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste Special Function Steven D Excel Worksheet Functions 8 November 3rd 08 06:40 PM
Special Date Function Christopher D Excel Worksheet Functions 1 September 10th 08 07:06 PM
Paste special function richzip Excel Discussion (Misc queries) 2 January 2nd 08 10:59 PM
Special function Bart Steur Excel Worksheet Functions 5 December 30th 05 05:59 PM
special function help needed DanceNFree Excel Worksheet Functions 5 May 10th 05 08:51 PM


All times are GMT +1. The time now is 02:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"