+ Reply to Thread
Results 1 to 7 of 7

Help! Quick question on summing series

  1. #1
    Registered User
    Join Date
    10-06-2010
    Location
    TX
    MS-Off Ver
    Excel 2003
    Posts
    3

    Help! Quick question on summing series

    Basically, I need to write a VBA function which evaluates the function "1/i" for values from i = 1 to n. n can be any integer larger than one. It then adds all those terms to get the final answer. For example, if n = 4, the sum would be (1/1) + (1/2) + (1/3) + (1/4) = 2.083

    I can make the formula which evaluates 1/n, but not sure how to add the series starting at 1. I am referencing n from a value on the spreadsheet, and then pasting the final answer back onto the sheet.


    So far here is what I have:


    Please Login or Register  to view this content.
    Last edited by killadrilla; 10-06-2010 at 02:13 AM.

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Help! Quick question on summing series

    Hi and welcome to the board, unfortunately

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  3. #3
    Registered User
    Join Date
    10-06-2010
    Location
    TX
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Help! Quick question on summing series

    thank you for letting me know, it's been fixed

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Help! Quick question on summing series

    You might need to retitle your thread (specifically remove "Help") but do you really need a UDF ?

    One formula based approach:

    =SUMPRODUCT(1/ROW(A$1:INDEX(A:A,$A$1)))

    where A1 holds n

    There are plenty of others.

  5. #5
    Registered User
    Join Date
    10-06-2010
    Location
    TX
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Help! Quick question on summing series

    Thanks, but is there a method that only uses VBA?

    Quote Originally Posted by DonkeyOte View Post
    You might need to retitle your thread (specifically remove "Help") but do you really need a UDF ?

    One formula based approach:

    =SUMPRODUCT(1/ROW(A$1:INDEX(A:A,$A$1)))

    where A1 holds n

    There are plenty of others.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Help! Quick question on summing series

    Please Login or Register  to view this content.
    but it will be slower...

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Help! Quick question on summing series

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1