+ Reply to Thread
Results 1 to 49 of 49

IF Funtion with coloured celld

  1. #1
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    IF Funtion with coloured celld

    Hi,

    Im trying to get a function to tell me:

    If cells B5 and B9 are the same and both of those have colours in cells X5 and X9 then say TRUE. If not say FALSE.

    Can anyone help?

    Thanks

    Este

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: IF Funtion with coloured celld

    You might need to provide a bit more info, are you saying for example that the cells X5 and X9 are colored or are you saying that those cells would contain a word like blue or red?
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    Thanks for your help smabo kid.

    Im saying that they are coloured. They have text in them but it is not always the same, so the colour is the variable that I want to use.

    Does that help?

    Thanks
    Este

  4. #4
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: IF Funtion with coloured celld

    From my perspective I think there is still more info missing.
    For example is there data in B6, B7 and B8 that you are ignoring? Do you want the formula to compare every 4th cell? If there is a word or something in X5 but it isn't a color what should happen then?
    So if B5 and B9 have a number if you will - both are 6, and X5 is blue but X9 is blank or has a 10 in it you want the output to be "false" right?
    Sometimes an attachment with what you have and a desired outcome is helpful.
    Last edited by Sam Capricci; 08-06-2013 at 09:42 AM.

  5. #5
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    I'm not sure that formulas alone can do that. I could be wrong. One of my files changes the color of a cell based on its contents with a function in the VBA editor. You could try that if you're ok doing that.
    ~~LaffyAffy13~~

    If I have helped you solve your problem, please be sure to click at the bottom left of my post.

    Thanks.

  6. #6
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    Example1.xlsxHi there,

    I have attached a sheet. Does that help?
    THe formular should be in the cells where it says TRUE and FALSE.

    Thanks

  7. #7
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Wait. So... You want cells B3:F6 to have formulas that state "TRUE" or "FALSE". I've understood that much. Now, when do you want these cells to say "TRUE" and when do you want them to say "FALSE"?

  8. #8
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: IF Funtion with coloured celld

    LaffyAffy, looking at it I'm struggling to interpret it but from what I can see...
    Can't discern a pattern yet for butter but for "cholesterol lowering" it appears that in B6 it is false because B15 and B18 are both not colored, C6 is false because C16 is colored but C18 is blank, D6 is true because both D15 and D18 are colored.

  9. #9
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Ok, so if the colors overlap from row to row anywhere with the same word in column A, it should say true.

  10. #10
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: IF Funtion with coloured celld

    I think you've got the pattern I was missing, yes it appears that if an item is colored more than once in the column below it should return true. Of course the poster will have to verify or disagree with that but it seems you've got the pattern.

  11. #11
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    I still don't see how that's possible with formulas alone. Do you?

  12. #12
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    yes, thats the coorect pattern.

  13. #13
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: IF Funtion with coloured celld

    LA, I wonder if that too. It might be done with a formula using conditional formatting but that would be a guess as I don't know how to make one that might be that complex. Other might be with visual basic and I have no experience with it. I will keep watching to see if you or someone else might be able to solve this one (and I'll play around with conditional formatting just in case).

  14. #14
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    esteloulou is it ok with you if I solve this with a public function in VBA

  15. #15
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    Is VBA - macros?

    If all I have to do is insert a moculde into the alt+F11 function then thats fine. I have a macro in my spreadsheet already and I dont know how to add another one but im sure its not too hard.

    Thanks

  16. #16
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: IF Funtion with coloured celld

    I think it could be doable with a formula under the following conditions.
    1) you can add a column that would do a countif to be countif Margarine appears in the column below and how many times.
    2) after you count them and the number appears to be greater than 1 you can then incorporate something like a lookup but you would need it to recognize a colored cell (any color would do) and it would have to know that that color needs to appear across from it at least twice in the same column to count as true.
    Now, one thing i did find was that you can do a find and replace on a color in a cell. For example I replaced the red cells with CL (for cholesterol lowering), they could be left colored or uncolored.
    Now that that was done I'm wondering if the formula might work. Onward.

  17. #17
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    sounds good im working on it

  18. #18
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: IF Funtion with coloured celld

    I'm wondering if this can be tweaked to fit.
    first, I added a duplicate of his data to rows 7-10. Then inserted new columns B and C to work with.
    I did a find and replace on the colors (some replaced by no color and left some as is, neither matters to what I was doing), then wrote the formula that I'm having trouble getting to work.
    =IF(COUNTIF(D$15:D$25,$B7>1),"TRUE","FALSE")
    you can see in the attached, I think the sequence is messed up.
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    The only caviat I have with the above is that I cannot write into the voloured boxes as there is already something in them that I cannot change.

    I am using the following macro to count the number of each coloured cells, although this is for a different purpose and does not refer to the Cholesterol Lowering, Baking etc titles, does that help?


    Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)

    Dim rCell As Range

    Dim lCol As Long

    Dim vResult



    ''''''''''''''''''''''''''''''''''''''

    'Written by Ozgrid Business Applications

    'www.ozgrid.com



    'Sums or counts cells based on a specified fill color.

    '''''''''''''''''''''''''''''''''''''''



    lCol = rColor.Interior.ColorIndex



    If SUM = True Then

    For Each rCell In rRange

    If rCell.Interior.ColorIndex = lCol Then

    vResult = WorksheetFunction.SUM(rCell,vResult)

    End If

    Next rCell

    Else

    For Each rCell In rRange

    If rCell.Interior.ColorIndex = lCol Then

    vResult = 1 + vResult

    End If

    Next rCell

    End If



    ColorFunction = vResult

    End Function

  20. #20
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Ignore this, its wrong.
    Last edited by LaffyAffy13; 08-06-2013 at 12:41 PM. Reason: took out some testing procedures

  21. #21
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Found some errors. Leave that alone.

  22. #22
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Here we go. This one seems flawless. Let me know if it works for you. What you need to do now:

    1. Copy the code below and paste it into your VBA editor, using Alt + F11.
    2. Place the following formula into the top left cell in the area that you wish to have either "TRUE" or "FALSE"
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    *B5 stands as only an example cell. It may not be the one you need to use
    3. AutoFill to the edges of your earlier said area.
    Please Login or Register  to view this content.

  23. #23
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    I tried using the color of the cell to match the colors, but my program was matching the blank cells as if they were white. So I went with the pattern instead. Hopefully all of your colored cells follow the same pattern lol

  24. #24
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    Hi there,

    It comes up with "VALUE hash tag".

    As I am not very proficient with macros, Im not sure its actually looking at the right cells. Do I need to change these in the macro?

    Thanks

    E

  25. #25
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Well...yeah. The only lines you would need to change are
    Please Login or Register  to view this content.
    Whichever column holds the "margarine, butter, cholesterol lowering, etc." needs to replace "A" in the first line and "A7:A" in the second.

    If that doesnt make sense, if you want to send me a private message with your real document, you can do that too. If you don't feel comfortable sharing that information, that's ok I can try to explain it on here.

  26. #26
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Let's say that the area that you want to say either True or False is now called "E" because I'm tired of retyping that haha. Ok so for each cell inside of E, the formula needs to be
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The X stands for whichever column each specific cell is in. The # stands for whichever row each specific cell is in. So for G6, the formula would be =esteloulou(G6) and for Q267 the formula would be =esteloulou(Q267) does that make sense? Are the cells that currently state "#VALUE" referencing themselves? Or are they referencing other cells?

  27. #27
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    This is complicated, I really need to thank you for your pateience with me, I promise I will give you the best feedback ever.

    The cells that the TRUE and FALSE refer to are in a different sheet. I dont suppose I can call you and we can share screens through join.me?

    Thanks

  28. #28
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Ohhhhhhhhhhhhhhhh you didnt tell me that. And no I don't know what that is.

  29. #29
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    Im sorry, I didnt realise it mattered? Can I not just replace "A" with the name of the spreadsheet and the cells I need within that?

    join.me means you can see my screen on yours, i would share mine, you wouldnt share yours. https://join.me/

    And?

  30. #30
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Ok so say E is in Sheet2 and the cells you are referencing are in sheet 1. For each cell in E, the formula now needs to say this:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  31. #31
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    I think I have now done everything of the above and it is still coming up with VALUE#

  32. #32
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    This is the macros I have now:


    Public Function esteloulou(tcell As Range) As Variant

    Dim lastrow As Long, ttype As String
    Dim typerange As Range
    Dim tp, tp2 As String


    ttype = Range("'Promo Split Out'!C8:C49" & tcell.Row).Text

    With ActiveWorkbook.Worksheets("Promo Layering")
    lastrow = .UsedRange.Row + .UsedRange.Rows.Count - 1
    End With

    For Each typerange In Range("'Promo Split Out'!E8:BE49" & lastrow)

    If typerange.Text = ttype Then

    tp = Cells(typerange.Row, tcell.Column).Interior.Pattern

    If tp = tp2 Then

    If tp <> xlNone Then

    esteloulou = "TRUE"

    End If

    End If

    If tp <> xlNone Then tp2 = tp

    End If

    If esteloulou = "" Then esteloulou = "FALSE"

    Next typerange

    End Function

  33. #33
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Nope, look at the post below. This one is wrong
    Last edited by LaffyAffy13; 08-07-2013 at 10:30 AM. Reason: Saw your posts

  34. #34
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    I think I found the problem. Try this one.
    Please Login or Register  to view this content.
    Can't test this one, as I don't have the file. But it should work.
    Last edited by LaffyAffy13; 08-07-2013 at 10:33 AM. Reason: Took off unneeded quotation marks

  35. #35
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Ignore this.

  36. #36
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    I have ignored as it doesnt work. thanks for your relentlesness

  37. #37
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: IF Funtion with coloured celld

    Quote Originally Posted by esteloulou View Post
    This is the macros I have now:
    esteloulou: Welcome to the Forum, but as a new member please review the forum rules. In particular, when posting code use CODE tags:
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  38. #38
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Success!!!!!!!! Finally. I tested this one on my own and it works.

    Please Login or Register  to view this content.

  39. #39
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    !!! Yes that has worked, the cells now come up with TRUE and FALSE which is good. But the values arent correct.

    In the formula esteloulou(#) what should that cell refer to?

    So sorry about this

  40. #40
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Haha it's ok. In the sample workbook you uploaded, the values were correct. I don't know what Promo Split Out or Promo Layering looks like, but in the sample workbook, in sheet 1, you had Margarine, Butter, Cholesterol lowering, and Baking. And to the right of it, the cells stated True or False. I can't tell you what to refer to with those cells, because I dont know what the workbook looks like and I don't know where the cells to reference are. Can you either upload a sample workbook that actually looks like your real file or upload pictures of those sheets? Otherwise I don't know what to tell you. And I can't do the whole "Join.me" thing because I'm at work and I'm just helping you with this to pass the time. I'm constantly working on other things so I don't have the time to do that, sorry.

  41. #41
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    Hi, ok no worries. Thanks so much for helping me out while you are at work!!

    I have attached images of the two sheets. Does that help. Do you see what Im trying to do?
    Attached Images Attached Images

  42. #42
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    I want to help you but I have no idea what you want to achieve. I can see the purple colors, and I'm guessing that if the purple repeats for one "Sector" then you want some cell to say True. But without the workbook I can't help you, because I have to rewrite the macro above to fit your file. I thought the sample workbook that you posted earlier would be similar to the file you currently have, so I wrote it to work for something that was visually similar. If you can't give it to me, you may have to study the code step by step, figure out what it is doing, and then change it on your own. I'm sorry, but for me to continue working with the resources you have given me is like hunting for buried treasure without a map. I would be happy to finish this job for you if you send me the workbook. If you can, please do so through a private message if the workbook contains important information that you don't want exposed on the internet.

  43. #43
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    Hi,

    cool ok. How do I send a private message?

    THANK YOU

  44. #44
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    <<<<<<Click my blue name to the left

  45. #45
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    Sorry, having a big blonde moment here. And then... ? I cant seem to see a private message button or anything like it?

  46. #46
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: IF Funtion with coloured celld

    If you click on his name a box will appear and a choice will include private message, then click on that and you can send LA a private message.

  47. #47
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    Lol sambo kid, you're alive. I figured you unsubscribed from the thread since it has 40+ posts

    esteloulou, my name, at the top left of this post, is blue. I removed my signature, so maybe that will help. Click it, then choose "private message"

  48. #48
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: IF Funtion with coloured celld

    esteloulou, I was hoping you would've emailed me the file by now. I could've worked on it today, but next week I'm off to college, and I won't have the time to help you out anymore. I could try to get back to you when possible, but that might not be for a while. If you need this soon, I hope you find what you are looking for. If not, I will do my best to work on it in the future. Good luck!

  49. #49
    Registered User
    Join Date
    08-06-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: IF Funtion with coloured celld

    Hi LA,

    I did send it to you on Friday? I sent you a private message asking how to attach the file (excel forum isnt hugely intuative).

    If you cannot do it now I will have to wait, thats my fault. However, if you could reply to my private message that would be great.

    Thanks

    Este

+ 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. Hide Rows if celld are empty
    By philipp.schaelli in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-08-2011, 07:54 PM
  2. vb for coloured rows.
    By dshilan in forum Excel General
    Replies: 2
    Last Post: 08-23-2011, 08:51 AM
  3. [SOLVED] Delete rows ere first cell is blank but ohters celld have data?
    By Mascot in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2006, 10:50 PM
  4. Coloured Cells
    By Becks in forum Excel General
    Replies: 3
    Last Post: 02-08-2006, 08:50 AM
  5. [SOLVED] coloured marking
    By Roland Burger in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 04-14-2005, 09:06 AM

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