+ Reply to Thread
Results 1 to 7 of 7

Summing two columns in VBA

  1. #1
    Registered User
    Join Date
    11-29-2014
    Location
    California
    MS-Off Ver
    2013
    Posts
    5

    Question Summing two columns in VBA

    Hello,

    I would like a macro that would take the values from one column on one worksheet (Today) and sum them to another column on a different worksheet (Totals). The simplified version of what I'm looking for is something like this:

    Range("Totals!C3").Value = Range("Totals!C3") + Range("Today!C3")

    But instead doing this for just two cells, the macro would do this for over a hundred cells in one column. I have no idea how to do this besides copying and pasting the above formula for each row but I figure there must be a code that would automate that process for me and be much simpler to manipulate.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Summing two columns in VBA

    Hi rogerpops,

    Welcome to the Forum!


    Try this and let me know of issues:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    11-29-2014
    Location
    California
    MS-Off Ver
    2013
    Posts
    5

    Re: Summing two columns in VBA

    Thanks for the welcome

    I think I see what this formula is doing and how I wasn't clear on my part as to what I was looking for. So it looks like it sums up all the values in "Today" column C and then puts that into "Totals" C3. What I am looking for, instead, is not a total sum of the column, but taking each cell in that "Today" column and adding it to the identical cell in the "Totals" column. But I've got over a hundred rows in that column so it would be a little time consuming to write it out for each row.

    So, to kind of illustrate this better, let's say in the Today sheet in column A, I've got three rows: Apples, Orange, Bananas. Then the B column has the total number sold that day for each of those items. In the Total sheet I have the same two columns, but the B column has the total I've sold over every day I've tracked thus far, and I want to add the current "Today" sheet values in there as well. This way I can clear the "Today" sheet and input new values when they come but the "Total" sheet won't be affected until I run the macro and the new values from the "Today" sheet are added in. Then I get to see the new total of Apples, total of Oranges and total of Bananas.

    Does that make any sense? It is surprisingly hard for me to describe in words.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Summing two columns in VBA

    Try this instead


    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Summing two columns in VBA

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-29-2014
    Location
    California
    MS-Off Ver
    2013
    Posts
    5

    Re: Summing two columns in VBA

    Quote Originally Posted by xladept View Post
    Try this instead


    Please Login or Register  to view this content.
    Works beautifully! Thanks!

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Summing two columns in VBA

    You're welcome and 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. Summing Columns-revolves around summing particular items
    By savv32 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-06-2005, 09:05 PM
  2. [SOLVED] Summing Columns-How do I add non-numbered columns in excel?
    By Highlander in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-28-2005, 12:05 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