View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Lotus 123 @nsum function equivalent in excel(?)

If you want something more "friendly" looking that the other solutions
posted so far, you can create a User Defined Function to duplicate the
functionality of the NSUM function. From a worksheet, press Alt+F11 to get
into the VBA editor and select Insert/Module from its menu bar, then
copy/paste the following code into the code window that opened when you did
that...

Function NSUM(Offset As Long, SkipAmount As Long, Rng As Range) As Double
Dim X As Long
With Rng
If .Rows.Count 1 And .Columns.Count 1 Then
MsgBox "This function only works with single rows or single " & _
"columns!", vbCritical, "Improper Range Specified"
End If
If .Rows.Count 1 Then
For X = 1 + Offset To .Rows.Count Step SkipAmount
NSUM = NSUM + .Cells(X).Value
Next
Else
For X = 1 + Offset To .Columns.Count Step SkipAmount
NSUM = NSUM + .Cells(X).Value
Next
End If
End With
End Function

Now, go back to the worksheet and enter this into a cell...

=NSUM(1,3,B5:B15)

and it should produce the sum that you are looking for.

--
Rick (MVP - Excel)


"marke54805" wrote in message
...
I have an old lotus 123 spreadsheet (a budget) that used the @nsum
function.
It allowed me to sum every third or forth column. The text below shows
the
syntax. My question... does excel have a function like this?

Adds every nth value in list, starting at offset.
Syntax
@NSUM returns the sum of (offset), (offset + n), (offset + 2n), (offset +
3n), ... in list. @NSUM(0;1;list) returns the same result as @SUM(list).
Example
@NSUM(1;3;B5..B15) returns the sum of the values in B6, B9, B12 and B15.

Thanks in advance,

mh