+ Reply to Thread
Results 1 to 3 of 3

Amending formula to divide by the first number in the range used.

  1. #1
    Forum Contributor
    Join Date
    06-25-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    179

    Amending formula to divide by the first number in the range used.

    Hello All,
    I've written a function in VBA that did the tast i initially wanted (till i found out it was wrong)
    My new piece of code doesn't do what i need it to and i don't know how to ammend it.
    Currently my code does the following:
    WAvgCost = WAvgCost + volume.Cells(numRows) * priceOnDay(numRows) / targetVolume
    It then will repeat this and add and so forth. (see full code bellow)
    The one ammendment i need is for it to divide the summed WavgCost by the first PriceOnDay and then minus that figure by 1.

    So full code is:

    Please Login or Register  to view this content.
    What i need is a statement at the end that takes that takes WAvgCost and divides is by the first priceOnDay used and then minus 1 from that number then it needs to be placed in result(4) = difference.

    Hope this makes sense.

    I just don't know how to get it to use the first price on day. I think im just having a brain melt down.


    Example Sum:
    Target Volume: 10,000
    Aggregate volume 1: 2097.2
    Aggregate volume 2: 2650.4
    Aggregate volume 3: 2318
    Aggregate volume 4: 2979.4

    Price Day 1: 13.09
    Price Day 2: 12.7
    Price day 3:12.41
    Price day 4: 12.73

    {[((2097.2*13.09)/10000)+((2605.4*12.7)/10000)+((2318*12.41)/10000)+((2979.4*12.73)/10000))] / 13.09} - 1 this should give you something like 0.028 or a change -2.8%

    Please help me :D

  2. #2
    Forum Contributor
    Join Date
    06-25-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    179

    Re: Amending formula to divide by the first number in the range used.

    I've still been unable to solve this. Any chance of some help?

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Amending formula to divide by the first number in the range used.

    It seems like it should be as easy as:

    1) Somewhere capturing the first value and storing it in a variable firstval='reference to cell containing first value'.value I can't immediately tell where you are storing this value, but I assume you know where it is and should be able to figure out the reference to that cell.
    2) then at the end add result(4)=wavgcost/firstval-1. you'll need to add the 4th element to results dim statements.

+ 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