+ Reply to Thread
Results 1 to 18 of 18

Modify code to change Sum Range

  1. #1
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Modify code to change Sum Range

    This formula will find the top and bottom in a column and sum it

    I need it to find the top and bottom addresses from column P (10) but to Sum from Column Q (11).

    Please Login or Register  to view this content.
    Last edited by ker9; 11-30-2010 at 03:31 PM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Modify code to change Sum Range

    You would do best to post a sample workbook showing your data layout and requirements,
    I can see several potential pit-falls in your code.

    It should clearly illustrate your problem and not contain any sensitive data.

    Cheers
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Modify code to change Sum Range

    Hi,

    How about
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Modify code to change Sum Range

    Thanks - workbook attached

    Active cell is F56 (pink) for testing purposes
    I'm working my way (the hard way) to getting a subtotal of each group on to the office subotal line. I've copied the subtotal values over to columns Q-W, I'm using Start/End in column P to give me the range to total


    Response from Richard doesn't work as it hard codes Q11 rather than finding the top cell in column P

    Thank you for any assistance!
    Attached Files Attached Files

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Modify code to change Sum Range

    Hi,

    Is column P contiguous? In which case try substituting

    Please Login or Register  to view this content.
    If not you may find an end down from P1 would be better.

    Rgds

  6. #6
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Modify code to change Sum Range

    Hi, Richard,

    I have a Start cell and an End cell labeled in column P
    My active cell is F56
    I want to go over 10 to P and xlup to "start" to get the row #s to sum, but sum them from Q
    The code below correctly gets the range in column P, but sums column P when I'd like to sum Q
    Your code is summing Q65-Q101, so it's going down from 56 even though it uses xlUp, which I don't understand.
    P is not contiguous
    You can look at my workbook to see what I'm trying to accomplish. Once I get this formula working, it will be put in a loop to work on all Office subtotal lines (I hope)

    Please Login or Register  to view this content.
    Thanks for any help!

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Modify code to change Sum Range

    Try this
    Please Login or Register  to view this content.

    This should subtotal the sequence START/END
    There must be an equal number of "START"s and "END"s in Column P

    Hope this helps

  8. #8
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Modify code to change Sum Range

    Marcol,

    OMG! Thank you! That is so very helpful!!

    I would love your opinion - is copying the group numbers out and using your formula the best way to get the group subtotals onto the office subtotal line?

    Thank you so much

    Karin

  9. #9
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Modify code to change Sum Range

    Can't look at it just now. I'll check when I get back.

    (Remember the time difference, it's evening here.)

  10. #10
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Modify code to change Sum Range

    Have a wonderful evening! Hope to connect again tomorrow sometime.

  11. #11
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Modify code to change Sum Range

    Try this workbook to see if it suits your needs.

    1/. Select the START point you need from the drop-down in Column P, make sure it is adjacent to one of the group names in Column O

    2/. Select, again from the drop-down, your END point. This should be in the row you want the result to be shown.

    3/. Run the macro

    To change the selection clear the values, one by one, in column P, this will clear the old group sub-totals, use delete or clear contents, not clear all

    This is not bullet proof, just a test to see if I'm on the right track.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Modify code to change Sum Range

    Hi, Marcol,

    Thank you - this is on the right track. I want to put the start/end in through VBA

    I appreciate your assistance very much!

  13. #13
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Modify code to change Sum Range

    Before you can do that we need to know the rules you are applying.

    I thought you were after sub-totalling variable groups of figures, in my opinion that would best be done as I suggested in my last post.

  14. #14
    Registered User
    Join Date
    11-27-2010
    Location
    USA
    MS-Off Ver
    KY
    Posts
    1

    Re: Modify code to change Sum Range

    You would do best to post a sample workbook showing your data layout and requirements,
    I can see several potential pit-falls in your code.

  15. #15
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Modify code to change Sum Range

    Hi dallasallenz

    Why have you quoted my first Post?

    If you can see something I have missed, you can get the latest sample from Post #11

    Any help is greatfully received on this Forum.

  16. #16
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Modify code to change Sum Range

    Hi, Marcol,
    I just want you to know that I am here and able to work on this now (finally past the Thanksgiving holiday and all the cleaning, cooking, relatives and time that it entailed - very thankful for you and everyone here who helps me!)
    I'm going to work it all through and attach a workbook, but it will take me a while.
    Thank you!!!!

  17. #17
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Modify code to change Sum Range

    No problem,

    Just as a point warning, beware the revenge of the turkey..

    From 20 turkey eggs in 1950 to 7m birds annually in 2010, Bernard Matthews became the largest turkey farmer in Europe
    He died at thanksgiving this weekend, mind you he was 80......

  18. #18
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Modify code to change Sum Range

    Hi, Marcol,

    Here it is, everything is working very well. It may not be the absolute best way to do things, but it is getting is done.

    I just need to figure out how to make the Grand totals a sum instead of hard coded so that it will total up the manual entry/calculated numbers in columns J and L. (user can put in a percent in column I or change column J to an amount)

    Thank you so much!!!
    Attached Files Attached Files

+ 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