+ Reply to Thread
Results 1 to 4 of 4

Subtotal using LastRow of a different column

  1. #1
    Forum Contributor dagindi's Avatar
    Join Date
    06-02-2008
    Location
    New York, NY
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    295

    Subtotal using LastRow of a different column

    Attached is test spreadsheet.

    I am trying to insert a formula into a macro that will allow me to change the formula "K4=subtotal(9,K6:K225)" to "K4=subtotal(9,K6:LastRow based on column G)"

    - Row 4 will always hold the formula
    - Row 6 will always be the starting point for the subtotal.

    I tried a bunch of different codes (see the modules attached) and cannot seem to get any of them to work. I am trying to avoid having to put K6:K65536

    Side note... the formula in "K4" will be applied to other columns as well but once I get the above solved, I have the solution already to paste it across.

    Any help or recommendation is greatly appreciated.
    Attached Files Attached Files
    Last edited by dagindi; 07-20-2010 at 10:23 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,993

    Re: Subtotal using LastRow of a different column

    Close ;-)

    Please Login or Register  to view this content.

    Regards

  3. #3
    Forum Contributor dagindi's Avatar
    Join Date
    06-02-2008
    Location
    New York, NY
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    295

    Re: Subtotal using LastRow of a different column

    TMShucks,

    Thanks so much for the response.

    It took me a few more tries (and hours) and I came across another thread that I was able to disect to get me to something very close to what you provided below. You can click HERE to see the thread I used.

    The code I worked off of is:

    Please Login or Register  to view this content.
    I ended up cutting out everything but:

    Please Login or Register  to view this content.
    I changed what needed to be changed to conform to my macro/worksheet but was still having problems.

    I caved in and checked your response and found that the code you provided:

    Please Login or Register  to view this content.

    versus the one I copied and modified:

    Please Login or Register  to view this content.
    was the main problem.

    I'm not sure why, but I am very grateful for your response which enabled me to finish this leg of the macro.

    Thank you!!

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,993

    Re: Subtotal using LastRow of a different column

    You're welcome. Thanks for the feedback.

    The "other" code that you copied is using column D to get the last row of data, whereas, you said column G had the most information ... problem 1.

    And it looks as though the code you copied was adding the subtotal at the bottom rather than the top ... problem 2.

    The two lines of code that you point to as the "main problem" do the same thing, just expressed differently ... as is common in VBA

    But, you have your solution, so all is well.

    Regards

+ 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