Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User Defined Function

Status
Not open for further replies.

Corbie

Technical User
Nov 19, 2001
21
GB
Can anybody help. I need to write a UDF that given a range (part of a row) sums every 4th number.

Any Ideas

Thanx

 
Code:
Option Explicit

Function SumEveryFourth(ARange As Range) As Double
Dim c As Range
Dim nCounter As Long

  For Each c In ARange
    If nCounter = 3 Then
      SumEveryFourth = SumEveryFourth + c.Value
      nCounter = 0
    Else
      nCounter = nCounter + 1
    End If
  Next c
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top