+ Reply to Thread
Results 1 to 6 of 6

Using VBA to sum cells of a certain color

  1. #1
    Registered User
    Join Date
    02-28-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    3

    Using VBA to sum cells of a certain color

    Hi,

    I have been asked to sum a spreadsheet by the cells' highlighted color. I understand I can do those through VBA but have not been able to get the macro right.

    If the cell range of my data is I5:S110 the the cell with the background color is A114 could some one give me the correct code?

    Thank you for your help,

    Wayne
    Last edited by wmatt140; 02-28-2012 at 02:02 PM.

  2. #2
    Forum Expert
    Join Date
    09-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    2,278

    Re: Using VBA to sum cells of a certain color

    Hello
    I'm no expert with VBA but I've previously used the following code to do something similar to what you're trying to do. I've amended the code for the ranges you mention. It returns the count into cell A1. If the code is not very efficient maybe one of our forum VBA gurus can suggest an improvement.

    Please Login or Register  to view this content.
    Hope this helps.

  3. #3
    Registered User
    Join Date
    02-28-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Using VBA to sum cells of a certain color

    DBY,

    Thank you for the reply. That gave me a count of the cells with a certain color. How can I get the sum of the values in those cells?

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Using VBA to sum cells of a certain color

    I believe you can just change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-28-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Using VBA to sum cells of a certain color

    That did it!

    Thank you all for your help.

  6. #6
    Registered User
    Join Date
    02-16-2012
    Location
    Atlanta, Georgia, USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Using VBA to sum cells of a certain color

    Is there an argument you can use in CountA that will do the same thing? I've tried several ways to no avail.

+ 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