+ Reply to Thread
Results 1 to 9 of 9

VBA for Autosum up on multiple cells

  1. #1
    Registered User
    Join Date
    09-06-2010
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Excel 2007
    Posts
    5

    VBA for Autosum up on multiple cells

    Dear excel experts i need very urgent help on my file. This file is done every month end. Here is the story. i receive a raw data extracted from accounting software and i do formating on it. Reapplying sums, coloring, bordering.... etc. My problem is when i record a macro to autosum up all of my "sub" categories. Excel just captures static addresses. I want to make this sum range dynamic. because every month record numbers vary. please have a look at my attached file. I looked for a solution for this matter for whole night couldn't find anything. Can be there any easy way to do it automatically, dynamicaly?
    Attached Files Attached Files
    Last edited by moonoo; 12-09-2010 at 02:46 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA for Autosum up on multiple cells

    Your sample workbook appears to be showing your final result. Why not post your macro and an unformatted raw sheet so we can see what you do, then help adjust your actual macro to add they dynamics you want?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    09-06-2010
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: VBA for Autosum up on multiple cells

    Thank you for your reply. Actually this not the final results, if you see cells highlighted in red, they supposed to have Subtotal function which covers its above records.
    Now how i do is, i filter my worksheet J column by "Sub" and apply autosum on those SUM cells manually. if there are over 1000 "Sub" elements, it's done manually. Attached files are source (need to be formatted) and another one is my macro.which does until this "Sub" thing.. thank you.
    Attached Files Attached Files

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA for Autosum up on multiple cells

    Hi moonoo

    I'm a little confused here. Your original file you posted "Formatting.xlsx" looks nothing like the most recent file "123465.xls". Which file is it that we should be working on?

    John
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA for Autosum up on multiple cells

    Hi moonoo

    This code appears to work on your original file "Formatting.xlsx"
    Please Login or Register  to view this content.
    You'll need to save it as a Macro Enabled file (xlsm).

    John

  6. #6
    Registered User
    Join Date
    09-06-2010
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: VBA for Autosum up on multiple cells

    Hello John,

    Thank you for you time.
    I tested your code and it selects my C columnt instead of H. which holds my transaction amounts.

    I've one idea. i'm not sure whether this is possible or not. The concept is, since i can filter and select only Subtotal cells. Can you do simple code to detect my auto sum range (like excel auto sum guess) above a single Subtotal cell, and SUM UP then shift down to next subtotal cell and search and sum up again etc,. It loops through until it finds no more used cell below last one. How does it sound? is it possible.


    Thanks
    Moonoo

  7. #7
    Registered User
    Join Date
    09-06-2010
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: VBA for Autosum up on multiple cells

    One more thing on my last uploaded sample files. You just delete some "IN" or "CJ" from A column and respective records in B column of 123465.xls and select whole worksheet n COPY, PASTE to New Macro.xlsm and run MASTER macro from macro list. which i've managed to record so far.
    The problem is i cannot record this Excel AUTOSUM action in Macro dynamically. when i record it just captures static cell addresses.

    tks,
    Moonoo

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA for Autosum up on multiple cells

    Hi moonoo

    It's my understanding that you want formulas in the Red Cells in column H of the attached file. The code in the attached workbook does just that on my platform.

    The code indeed works off of column C but only for purposes of finding "areas" that fit into a subtotal. Run the code...check the Red Cells. Formulas should be there.

    If the procedure doesn't do what you require, let me know.

    We can discuss your
    last uploaded sample files
    once I'm certain I understand your needs on your first uploaded file.

    John
    Attached Files Attached Files
    Last edited by jaslake; 12-08-2010 at 11:18 PM.

  9. #9
    Registered User
    Join Date
    09-06-2010
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: VBA for Autosum up on multiple cells

    Oh, god. Thanks John, It works like charm. Hurray. Thank you soooo much.

    Big fan.

    Moonoo
    \o/

+ 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