Working built-in function won't work within User-defined function

roscoe

Well-known Member
Joined
Jun 4, 2002
Messages
1,046
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Excel includes the builtin function SERIESSUM( x, n, m, coefficients ). All examples I have found show the coefficients as an array such as {1,1,1,1}.

I used that in the following on my spreadsheet: =SERIESSUM( C39, 1, 1, {1,1,1,1,1} ) and it works as desired.
However, I want to make a simpler version by putting this within a user defined function such as:
VBA Code:
Function RateB(RateA)
    RateB = SERIESSUM(RateA, 1, 1, {1,1,1,1,1} )
End function
Seems easy enough...but VB throws an error that "{" is not a valid character. I've also tried it with application.seriessum but that fails also.

Ideas?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Have you tried putting the array into a range then passing that range to the formula

VBA Code:
Function RateB(RateA)
    RateB = SeriesSum(RateA, 1, 1,1, A1:A5 )
End Function
 
Upvote 0
I haven't...it never changes so I wanted to do it all within the user function. I can give that a try though

Nope: VB didn't like the ":"
 
Upvote 0
Haven't got Excel atm, so try...adjusting your array to suit
VBA Code:
Function RateB(RateA)
    RateB = WorksheetFunction.SeriesSum(RateA, 1, 1, Range("A1:A5"))
End Function
 
Upvote 0
VB didn't object to that...but when I entered =RateB(c39) I got #NAME?.

Been a long time...not sure what I'm doing wrong.
 
Upvote 0
Try
VBA Code:
Function RateB(RateA)
    RateB = WorksheetFunction.SeriesSum(RateA, 1, 1, Array(1, 1, 1, 1, 1))
End Function
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,660
Members
449,114
Latest member
aides

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top