+ Reply to Thread
Results 1 to 3 of 3

VBA Code help - first timer

  1. #1
    Registered User
    Join Date
    06-09-2005
    Posts
    1

    VBA Code help - first timer

    Hello all,

    I am trying to write a UDF for Excel, and I haven't worked with VBA programming before. Here is what I want to do:

    Two columns next to each other (for example, a and b, but not necessarily those exact columns). Column A is filled with "distribution" amounts, are long decimal numbers (ie .0084840). Column B is filled with matching dollar amounts (ie 10.75). So, cells A1 and B1 are a "record" or match, A2 and B2, all the way down to An and Bn (n being any number). What I want to do is take the distribution amounts, divide it by the dollar amount (ie A1/B1), add one to the fraction, then multiply all records together. In other words:

    (1+(A1/B1))*(1+(A2/B2))*(1+(A3/B3))*.........*(1+(An/Bn)).

    Any help? post back here or email me at [email protected]

    Thanks in advance!

  2. #2
    Bob Umlas
    Guest

    Re: VBA Code help - first timer

    Not NECESSARY to use a UDF - this formula will do the job. If your data is
    A1:B13, ctrl/shift/enter this:

    =PRODUCT((1+A1:A13/B1:B13))

    Bob Umlas
    Excel MVP

    "Poots" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hello all,
    >
    > I am trying to write a UDF for Excel, and I haven't worked with VBA
    > programming before. Here is what I want to do:
    >
    > Two columns next to each other (for example, a and b, but not
    > necessarily those exact columns). Column A is filled with
    > "distribution" amounts, are long decimal numbers (ie .0084840). Column
    > B is filled with matching dollar amounts (ie 10.75). So, cells A1 and
    > B1 are a "record" or match, A2 and B2, all the way down to An and Bn (n
    > being any number). What I want to do is take the distribution amounts,
    > divide it by the dollar amount (ie A1/B1), add one to the fraction,
    > then multiply all records together. In other words:
    >
    > (1+(A1/B1))*(1+(A2/B2))*(1+(A3/B3))*.........*(1+(An/Bn)).
    >
    > Any help? post back here or email me at [email protected]
    >
    > Thanks in advance!
    >
    >
    > --
    > Poots
    > ------------------------------------------------------------------------
    > Poots's Profile:

    http://www.excelforum.com/member.php...o&userid=24154
    > View this thread: http://www.excelforum.com/showthread...hreadid=377806
    >




  3. #3
    Tom Ogilvy
    Guest

    Re: VBA Code help - first timer

    =SUMPRODUCT(1+A1:A10/B1:B10)

    --
    Regards,
    Tom Ogilvy

    "Poots" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hello all,
    >
    > I am trying to write a UDF for Excel, and I haven't worked with VBA
    > programming before. Here is what I want to do:
    >
    > Two columns next to each other (for example, a and b, but not
    > necessarily those exact columns). Column A is filled with
    > "distribution" amounts, are long decimal numbers (ie .0084840). Column
    > B is filled with matching dollar amounts (ie 10.75). So, cells A1 and
    > B1 are a "record" or match, A2 and B2, all the way down to An and Bn (n
    > being any number). What I want to do is take the distribution amounts,
    > divide it by the dollar amount (ie A1/B1), add one to the fraction,
    > then multiply all records together. In other words:
    >
    > (1+(A1/B1))*(1+(A2/B2))*(1+(A3/B3))*.........*(1+(An/Bn)).
    >
    > Any help? post back here or email me at [email protected]
    >
    > Thanks in advance!
    >
    >
    > --
    > Poots
    > ------------------------------------------------------------------------
    > Poots's Profile:

    http://www.excelforum.com/member.php...o&userid=24154
    > View this thread: http://www.excelforum.com/showthread...hreadid=377806
    >




+ 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