+ Reply to Thread
Results 1 to 2 of 2

Cell Color Dependent Function

  1. #1
    Registered User
    Join Date
    06-06-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    11

    Cell Color Dependent Function

    I need to make a function (simple excel functions or a VBA macro - either works) that will detect the color of a referenced cell and return a TRUE/FALSE value - FALSE if the cell is colored yellow or red (the red coloring is done by auto-formatting), and TRUE if the cell isn't colored at all.

    Some specifics about what I'm trying to do - I work for a company that uses a lot of pumps and we use a GPS tag tracking system to keep track of our pumps. I'm doing some data mining and I have a pretty large spreadsheet that has a column for each pump we have in a certain area. Each row represents a date and the cells contain the GPS coordinates for each pump at each date.

    The spreadsheet's cells are filled with either GPS coordinates or with the word "Repair" (signifying that the pump was being repaired and not on the job site). I am trying to get a total of how many pumps were operating on-site on each day. My data sheet already tells me which pumps were being repaired, but it does not tell me which pumps were in transit or simply not in use. To find this out, I have gone through and marked off coordinates that are not at the job site by coloring those cells yellow. I have also marked the cells with the word "Repair" in them, but I used conditional formatting for that. I would like to use a SUMIF function along with the function I mentioned at the start of this post to find the total number of pumps that are being used at each date.

    I have attached an example spreadsheet with the desired results. Any cell labelled "GPS" just represents a cell with GPS coordinates in it - I didn't want to waste time making up fake GPS coordinates. The "Pumps on-site" column contains the results I'm after.

    Example spreadsheet is here.
    pump location example spreadsheet.xlsx

    *Update*
    Posted the same question on Ozgrid - http://www.ozgrid.com/forum/showthre...602#post669602

    Thanks a lot!
    Last edited by adm0104; 06-18-2013 at 11:40 AM.

  2. #2
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Cell Color Dependent Function

    I'm not sure exactly how and where you want this. but the Object I use is this...

    selection.interior.Color

    then you can do something like this:

    if selection.interior.color = vbRed OR selection.interior.color = vbYellow then
    'Set something to True
    end if

    Remember that colors are actually numbers and using vbRed is a code into that number.....HTH
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

+ 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