+ Reply to Thread
Results 1 to 10 of 10

VBA Sum Values By Row Heading

  1. #1
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    VBA Sum Values By Row Heading

    Hi, I wonder whether someone could help me please.

    Using a solution from @AB33 from a post I made here: http://www.excelforum.com/excel-prog...-headings.html, I've been able to put together a script which sums specific figures if a date field matches a column heading.

    In a live environment, I've also been able to make some changes to take account of additional filters I want to apply to the data extracted from the 'Source' to the 'Destination' sheets.

    I've now come across another hurdle, which I'm afraid my knowledge, or lack of it has led me to making a new post and is the last part of my project. Please note I did post this question here:http://www.ozgrid.com/forum/showthread.php?t=187735 and although I have been fortunate to receive many 'views', I've not been able to find an answer.

    What I'm trying to achieve is as follows by adaptation of the original code is as follows:

    Rather than totalling the figures from Column E on the "In Flight Projects" (Source) sheet, where the value in Column D matches the column headers on "Output" (Destination) sheet,
    I would, if at all possible please, like to total the figures from Column E on the "In Flight Projects" sheet where the value in Column B on the "In Flight Projects" sheet matches the rows in Column B on the "Output" sheet.

    I just wondered whether someone could possibly look at this please and offer some guidance on how I may achieve this.

    I appreciate that my description may not be the most straight forward, so I have attached a file to hopefully illustrate my issue.
    • The "In Flight Projects" sheet contains the raw data.
    • The "Desired Output" sheet illustrates how I'd like the final results to look, and
    • The "Output" sheet is being used to test the code.

    Many thanks and kind regards

    Chris
    Attached Files Attached Files

  2. #2
    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 Sum Values By Row Heading

    Hi Chris

    Try this
    Please Login or Register  to view this content.
    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.

  3. #3
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Sum Values By Row Heading

    Hi @jaslake, thank you for taking the time to reply to my post and for putting the script together is truly excellent.

    There are just a couple of minor issues though, I hope that's ok.

    • When the values are paste to column C on the "Output" sheet it is overwriting the values in column B. Is there any chance please that the existing values can be left intact please, and
    • I'm not sure whether you will have seen in @AB33's original code, but there is a line of code
      Please Login or Register  to view this content.
      which specifically looks for the value of "C&R" in column C on the "In Flight Projects" to decide which records to sum. Is there by any chance please that this could be included in your code?

    Many thanks and kind regards

    Chris

  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 Sum Values By Row Heading

    Hi Chris

    This Code will do this
    the existing values can be left intact
    Please Login or Register  to view this content.
    I have no clue what this means...ALL the records have C&R in column C
    to decide which records to sum
    Post a sample file that includes results as you define them.

    With this Code in your Sample File the results are the same as your desired output.

  5. #5
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Sum Values By Row Heading

    Hi @jaslake, thank you for coming back to me with this, I really appreciate it.

    I understand that the test file only shows "C&R" in column C, in live, there are however more values as per the attached file. Please note this has changed the "Desired Output" results.

    I hope this helps, and my apologies for the confusion.

    Many thanks and kind regards
    Attached Files Attached Files

  6. #6
    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 Sum Values By Row Heading

    Hi Chris

    Try this
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Sum Values By Row Heading

    Hi @jaslake, thank you very much for coming back to me so quickly with this. The code works brilliantly, thank you!

    Could I ask please, because I'm really wanting to learn from this, could you possibly add some notes to the code?

    Many thanks and kind regards

    Chris

  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 Sum Values By Row Heading

    Hi Chris

    Sure
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Sum Values By Row Heading

    Hi @jaslake, thank you very much for this and for all of your time and trouble.

    All the best and kind regards

    Chris

  10. #10
    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 Sum Values By Row Heading

    You're welcome...glad I could help. Thanks for the Rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. lookup values in a range,return corresponding column heading
    By aljaffa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-14-2011, 04:31 PM
  2. Using cell values as a heading
    By godonnygo in forum Excel General
    Replies: 1
    Last Post: 02-27-2011, 09:01 AM
  3. Returning Row Heading for Top 'X' values in a range
    By Powermonger in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-28-2008, 06:04 PM
  4. In a table produce an value by column heading and row heading
    By naflan in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-27-2005, 01:25 PM
  5. Comparing values and returning the column heading
    By Steven Brobst in forum Excel General
    Replies: 3
    Last Post: 02-04-2005, 10:06 PM

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