+ Reply to Thread
Results 1 to 6 of 6

Macro to calculate range by a percentage

  1. #1
    Registered User
    Join Date
    11-14-2008
    Location
    Brooklyn, NY, USA
    Posts
    53

    Thumbs up Macro to calculate range by a percentage

    Hi All,

    I'm trying to do a forecast of my organization's budget for the next five years and need to create scenarios where certain figures will either be increased or decreased by a specified percentage that varies from 5% to 20%. I have recorded eight macros that can accomplish this task, but I feel like there must be a more effienct method.

    In addition, I would like to increase or decrease the figures from either column H or column J. Column R is the results column. This is the macro I recorded that provides for a 10% decrease:

    Please Login or Register  to view this content.
    Since I recorded it, the macro is kind of hacky :-) Any help would be greatly appreciated!

    Cheers,
    Tim
    Last edited by judasdac; 06-26-2009 at 05:54 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro to calculate range by a percentage

    Hello Tim,

    I don't know if you have explored using Excel Scenarios for this purpose. It allows you to easily setup "what if" scenarios and test the outcomes. This may be a better option than recording a lot of macros. You can access the Scenario Manager from the menu Tools > Scenarios...
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    11-14-2008
    Location
    Brooklyn, NY, USA
    Posts
    53

    Re: Macro to calculate range by a percentage

    Hi Leith,
    Thanks for the response. I had considered using the scenario manager, but the range of cells where the values could be increased or decreased is 185 (R5:R190). Also, I have each fiscal year set up as a separate workbooks with 14 worksheets (12 months, beginning, and end) so I think macros would be more flexible.

    I would attach the file before we are blocked from uploading files. Ideally, I would be able to select either column H or J and then choose the percentage to increase or decrease those figures by.

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Macro to calculate range by a percentage

    Tim

    You sya the posted macro code works perfectly & that you want the results in column R

    Does not your macro place the formula & result in column Q


    Try this macro
    It asks the user toinput a percentage value
    e.g an entry10 = 10%
    It asks the user to select the data column
    If column H or J or any cell in those 2 columns are selected It places the formula in column R


    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  5. #5
    Registered User
    Join Date
    11-14-2008
    Location
    Brooklyn, NY, USA
    Posts
    53

    Re: Macro to calculate range by a percentage

    Perfect!! Thanks so muck Leith and Mudraker.

    The best part is that I actually understand this solution and should be able to replicate it in different situations.

    Learning something new is a great way to end the work week :-)

  6. #6
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Macro to calculate range by a percentage

    Darn, I did not make the code complex enough

    Now we have another member going to building & modifying their own macros

    Actually its good to see that you understand it & can updapt it for other uses
    Happy programming


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Last edited by shg; 06-26-2009 at 06:47 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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