David Evans
Active Member
Code:
Function SumIntervalCols(WorkRng As Range, interval As Integer) As Double
Dim arr As Variant
Dim total As Double
Dim j As Double
total = 0
arr = WorkRng.Value
For j = interval To UBound(arr, 2) Step interval
If IsNumeric(arr(1, j)) Then total = total + arr(1, j)
Next
SumIntervalCols = total
End Function
I use the above code to sum a range, most of which is Not Populated. The UDF sums every nth. column. Is there a better way of doing it so that columns that are empty are ignored? There are 225*80 cells that contain this UDF - but for the most part the columns are empty (I know, before you ask, it's a legacy worksheet and it's like the author's grandfather - he doesn't want to kill him off)
Is the If IsNumeric excluding any empty cells in the above code? It's recycled code
Thanks for you insight, as always
D