+ Reply to Thread
Results 1 to 6 of 6

Formula with Dynamic Ranges

  1. #1
    Registered User
    Join Date
    11-24-2005
    Posts
    11

    Formula with Dynamic Ranges

    Hi all,

    In Col E, I have a list of values which are summed on the final row. In Col H, I would like to display the percentage of the total that the row makes up i.e. if the total is 200 and E5 is 20, I would like H5 to display 10%.

    The number of rows will constantly be changing so I need a way of scripting for each cell in H to be =Etotal/Ecurrentrow, but I am having trouble working out the referencing for it and can't work out how to use a dynamic range or if I should use the code for counting up to the first non-empty cell and get it to do it for every filled in cell in the column, besides the final total (i.e. 100%) one.

    If anyone could provide any help, that would be amazing!

    Many thanks,

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

    Re: Formula with Dynamic Ranges

    Maybe =E5/(2*sum(E:E))

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Formula with Dynamic Ranges

    Maybe

    As a formula:

    =E5/Max(E:E)


    As a VBA sub

    Please Login or Register  to view this content.
    Last edited by Kyle123; 10-11-2011 at 10:01 AM.

  4. #4
    Registered User
    Join Date
    11-24-2005
    Posts
    11

    Re: Formula with Dynamic Ranges

    Apologies, I should have been clearer. I can do it manually however I wanted to use VBA as part of a much larger script to automate a complicated process. Everything else is working fine, but it is just this section that I am having trouble with.

    My current script creates a new worksheet, pastes all of the values from various worksheets into the new worksheet and arranges them in the correct order, now I am just trying to add the percentage column which doesn't feature on the various other worksheets.

    As I anticipate refreshing the data regularly, I am hoping not to have to manually edit the percentage formulae each time.

    Thank you,

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Formula with Dynamic Ranges

    does the above code do what you need?

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Formula with Dynamic Ranges

    Please Login or Register  to view this content.



+ 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