+ Reply to Thread
Results 1 to 4 of 4

Macro to Sum Columns based on Headers

  1. #1
    Registered User
    Join Date
    02-27-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    11

    Macro to Sum Columns based on Headers

    Okay so I'm fairly new to VBA but I've managed to to get this to partially work. I'm trying to make this sum the Columns and Bold the totals at the bottom of the Column based on the headers which will always be in the first row and start at Column M. I just don't know how to get it to search through the other headers it always stop after summing the first Column. I'm not sure if it has something to do with not making my sum formula variable instead of setting it at Column M.

    I've also included the ActiveWorkbook.Sheets line because I plan to eventually alter it to also repeat this process on a Sheet named Sheet2 after completing Sheet1 but I'm not sure if this line is the way to do it.

    Please Login or Register  to view this content.
    Last edited by Jluc; 03-24-2011 at 02:37 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Macro to Sum Columns based on Headers

    Hello Jluc,

    This macro will add the bold total line with the sum formula to each column header (starting at column "M") that matches your headers list. The list is marked in bold. You can add to or remove from the list if you want.

    The worksheet checked is "Sheet1". You can change this to another worksheet as well.
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 03-24-2011 at 02:21 AM.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to Sum Columns based on Headers

    Which version of Excel are you using?

    This is a function of the Table feature in Excel 2010
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    02-27-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Macro to Sum Columns based on Headers

    RoyUk,

    Unfortunately I'm not using Excel 2010,

    Leith Ross,

    That's perfect! Thanks!

+ 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