+ Reply to Thread
Results 1 to 12 of 12

IF cell is red

  1. #1
    Registered User
    Join Date
    08-20-2007
    Posts
    41

    IF cell is red

    Hi,

    I need to say:

    If [F10] is red, then: blah blah


    I'm looking to do this. Please can you instruct me on the green bit


    =IF(F10 IS RED,(F10/-1)+F9,F10+F9)
    Last edited by VBA Noob; 10-25-2007 at 07:42 AM.

  2. #2
    Registered User
    Join Date
    10-25-2007
    Posts
    35
    You'll need to use Visual Basic to do this. Either go Tools>Macro>Visual Basic Editor or hit Alt + F11. Then select your workbook in the left hand panel by clicking on "VBAProject (yourfilename.xls)". Next go Insert>Module and paste the following code into the new window:

    Please Login or Register  to view this content.
    Exit VBA and return to your workbook. Now change your formula to:

    =IF(ColorIndex(F10)=3,(F10/-1)+F9,F10+F9))

    The 3 above represents the colour index of red - to see a full list of excel colour indeces, click here:

    http://www.mvps.org/dmcritchie/excel...htm#colorindex

    Let me know if this helps.
    Last edited by owainl; 10-25-2007 at 07:50 AM.

  3. #3
    Registered User
    Join Date
    08-20-2007
    Posts
    41

    Question

    That doesn't seem to work. I'll explain more...

    I have cells that are represented as positive values which are actually negative. The text cells in these cells is red (not the cells themselves)

    I need to do something like this in G11

    =(IF(ColorIndex(G10)=3,(G10/-1),G10))

    in order to figure out which are negative and which aren't.

    The last answer I recieved didn't work...

    Please help

  4. #4
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,440
    Hi,

    Replace this

    Please Login or Register  to view this content.
    with this:

    Please Login or Register  to view this content.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  5. #5
    Registered User
    Join Date
    08-20-2007
    Posts
    41
    Do i have to save in visual basic or apply the module in some way to make it take effect?

  6. #6
    Forum Contributor corinereyes's Avatar
    Join Date
    12-02-2003
    Location
    Philippines
    MS-Off Ver
    MS Excel 2016
    Posts
    520
    Hi beesus311,

    Is the format category set to a Negative number (shows number as color red in a cell)? If that is that is the case you can use this formula:

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    Last edited by corinereyes; 10-29-2007 at 09:48 AM.
    Corine

  7. #7
    Registered User
    Join Date
    08-20-2007
    Posts
    41
    Unfortunately not. That is the problem. I need it to know that it is negative, but it just knows it's red.

  8. #8
    Forum Contributor corinereyes's Avatar
    Join Date
    12-02-2003
    Location
    Philippines
    MS-Off Ver
    MS Excel 2016
    Posts
    520
    Hi beesus311,

    If the font color is red try to put this on a VBA module:

    Please Login or Register  to view this content.
    then try this formula on the excel sheet:
    Please Login or Register  to view this content.
    If the fill color of the cell is red put this also in a VBA module:
    Please Login or Register  to view this content.
    then try this formula:
    Please Login or Register  to view this content.
    Try the excel sheet attached.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-24-2011
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: IF cell is red

    Hi, Thank you for the code and formula. It really helps, however, it does not get the result if the cell color was due to conditional formatting. is there another code to change for this? Thanks!

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: IF cell is red

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  11. #11
    Registered User
    Join Date
    01-06-2015
    Location
    noida
    MS-Off Ver
    2007
    Posts
    1

    Re: IF cell is red

    [QUOTE=beesus311;1842558]Hi,

    I need to say:

    If any cell is red, then: 0 without any VBA ...i dont know how can i set formula for this
    can anyone tell me how can i put formula for colour

    I'm looking to do this. Please can you instruct me on this...


    cell color is red than I get returned value is 0
    rake.png= 0
    Last edited by rraushan2088; 12-14-2016 at 05:05 AM.

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,917

    Re: IF cell is red

    rraushan2088 welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

    Also, color is cosmetic formatting, not data, and formulas work on data
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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