+ Reply to Thread
Results 1 to 25 of 25

Making certain cells with an “X” turn green (complicated formula)

  1. #1
    Registered User
    Join Date
    11-16-2019
    Location
    Liechtenstein, Vaduz
    MS-Off Ver
    365 MSO (64bit)
    Posts
    81

    Talking Making certain cells with an “X” turn green (complicated formula)

    green excel screen.jpg
    I have got this formula:

    =IF(OR(COUNTIF($AS2:$AW2,A$1),IF(ROW()>2,SUMPRODUCT(COUNTIF(INDEX($AS:$AW,ROW()-1,0),MOD(COLUMN()-1+{-2,-1,0,1,2},42)+1))>0,FALSE),IF(ROW()>2,SUMPRODUCT(COUNTIF(INDEX($AS:$AW,ROW()-2,0),MOD(COLUMN()-1+{-1,1},42)+1))>0,FALSE)),"X","")

    In general I've got a set of 42 number ranging from 1 do 42 in normal order. Now I pick 5 random numbers out of those 42. They are presented in cells from AS to AW. Now I want every nubmer out of those 5 to be represented as an X and that previous X then creates 5 Xs below it and 2 Xs below those as shown in the screenshot.

    Now, the screenshot depicts what I would like fully to achive. With the current formula I'm albe to get the "basic pattern". I would like additionally to turn some Xs green when a nubmer was selected that has been previously been covered by an X, and also it would be also nice when the total number of the green Xs would be shown in the AQ column.

    Now, I could perfectly live with that, but if there is any chance to make the cells turn black when a number was selected that was not covered by an X I would be in heaven

    Thank you in advance
    Attached Files Attached Files
    Last edited by bansche123; 11-16-2019 at 01:47 PM.

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Making certain cells with an “X” turn green (complicated formula)

    when a number was selected that was not covered by an X
    what do you mean "covered"?
    turn some Xs green when a nubmer was selected that has been previously been covered by an X
    not clear
    can you give an an example?

  3. #3
    Registered User
    Join Date
    11-16-2019
    Location
    Liechtenstein, Vaduz
    MS-Off Ver
    365 MSO (64bit)
    Posts
    81

    Re: Making certain cells with an “X” turn green (complicated formula)

    Thank you very much for your reply, I am more than happy to provide an explanation

    Alright, by „covered with an X” I mean the situation when a cell is filled with an “X” due to the “basic pattern” I have created. To give you a example, as you can see in the first set of 5 random numbers there is an 8 (which is the first number which was selected in selection process which has the aim of picking 5 random numbers out of the 42)

    Now, the 8 is located in H2, it is black, because this is the first row, now according to the “basic pattern” the 8 creates 5 Xs in the row below itself ranging from F3 to J3 as well as 2 Xs two rows under itself, namely G4 and I4.

    Now during the next process of picking 5 numbers a 9 was selected. The 9 occupies cell I3. I happens that I3 is a cell with an X due to the previous “basic pattern” that was used on the 8. In this instance I want that X to have a green background.

    Now you can also see, that in the second process of picking 5 numbers a 12 was selected. The 12 sits in cell L3, which was not filled with an X, and therefore the background of this cell is supposed to be black.

    Should you have any other questions, please do not hesitate to ask
    Last edited by bansche123; 11-17-2019 at 05:33 AM.

  4. #4
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Making certain cells with an “X” turn green (complicated formula)

    not clear
    but you can catch your pattern with this formula:
    =AND(A2="X",SUMPRODUCT(($AS$12:$AW$13="X")*(OFFSET(A2,1,-2,2,5)="X"))=7)
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-16-2019
    Location
    Liechtenstein, Vaduz
    MS-Off Ver
    365 MSO (64bit)
    Posts
    81

    Re: Making certain cells with an “X” turn green (complicated formula)

    Thank you very much for your help and reply

    I can see that like 90% is clear to you I apologize for doing a terrible job at explaining, but now I think it will be easer as you know the pattern and you have created your own formula for it.

    The only thing that would have to be modified in order to achieve what I was writing about earlier is the fact that in some cases the “basic pattern” would need to have a green cell on top instead of a black one. What is also important to notice that in my formula the cell with the black background also contains as “X”, you just can’t see it since the background as well as the “X” are both black and therefore the letter is invisible. I know I haven’t placed an “X” in the “basic pattern” which I strongly apologize for, because this has probably thrown you off. However in my formula this “X” in the top cell is included, so the pattern without the black background in the top cell looks like this (look screenshot attachment):

    Now, essentially it is all about this” X” in the cell on top. The background colors for it are black or green depending on whether a number was chosen which cell has been or hasn’t been filled with an “X” before the selection took place, due to the basic pattern that was used on the numbers picked in the previous number picking. In case it was filled with an X I would like the background to be green, if there wasn’t an “X” I would like the background to be black.

    Maybe this will make it easier to envision — think of it as kind of a game where you get a point when you manage to pick the “right number” (which in this case would be all numbers with an “X” in their cells) and that because “you won” the background becomes green, also respectively “not winning” so picking a number with no “X” inside their cells means losing and therefore the background of that cell has to be black. (look screenshot attachment)

    I am sorry I write this much, but I really hope I explained it understandably
    Attached Images Attached Images
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,535

    Re: Making certain cells with an “X” turn green (complicated formula)

    This proposal employs four conditional formatting formulas in the following order:
    For A4:AP17 (Green): =AND(COUNTIFS($AS4:$AW4,A$1),OR(COUNTIFS($AS2:$AW2,A$1-1),COUNTIFS($AS2:$AW2,A$1+1)))
    For A3:AP17 (Green): =AND(COUNTIFS($AS3:$AW3,A$1),OR(COUNTIFS($AS2:$AW2,A$1-2),COUNTIFS($AS2:$AW2,A$1-1),COUNTIFS($AS2:$AW2,A$1),COUNTIFS($AS2:$AW2,A$1+1),COUNTIFS($AS2:$AW2,A$1+2)))
    For A2:AP17 (Black): =AND(A2="x",COUNTIFS($AS2:$AW2,A$1),COUNTIFS($AS1:$AW1,A$1)=0)
    For A2:AP17 (Green): =AND(A2="x",COUNTIFS($AS2:$AW2,A$1))
    Note that the formulas in rows 18:33 are not needed, they are only left for demonstration of how the formatting formulas are applied.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  7. #7
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Making certain cells with an “X” turn green (complicated formula)

    As I was read your 1st post, I think that you only need condition format,
    That's mean 1 and 42 will NEVER got a green mark, right ?
    I don't need to takecare contents in cell that got 'X' or not, right ?
    Just to check that if X was 'covered' with other 'X' (left & right) and listed in AS-AW, mark green or
    if X was NOT 'covered' with other 'X' (left & right) and listed in AS-AW, mark black.

    If yes, just use a conditon format

    B2 : Mark Green
    Please Login or Register  to view this content.
    Note after insert column AS-AW will change to AT-AX

    B2 : Mark Black
    Please Login or Register  to view this content.
    Note after insert column AS-AW will change to AT-AX

    And for count how many X was covered, I need to insert a column between AP-AQ, so AQ will change to AR
    and at AR2 can use this formula.
    Please Login or Register  to view this content.
    Press Ctrl-Shift-Enter for Array formula.

    But I doubt , why my result in the row 2 and 5 is differnt from your's.
    Row 2 : I've got 1, you've got 0
    Row 5 : I've got 3, you've got 2


    Regards.
    Attached Files Attached Files
    Last edited by menem; 11-19-2019 at 11:01 PM. Reason: Add note

  8. #8
    Registered User
    Join Date
    11-16-2019
    Location
    Liechtenstein, Vaduz
    MS-Off Ver
    365 MSO (64bit)
    Posts
    81

    Re: Making certain cells with an “X” turn green (complicated formula)

    JeteMC and menem I would like to thank you both very much for your help I very much appreciate it. Thank you Gentlemen

    JeteMC Form what I can see you have got everything right Thnak you Sir. The only thing left would be to add the total number of green Xs in each row

    menem I have utmost respect for people who try to help other people especially when they do it in a foreign language, and btw. I'm not a native english speaker, but from what I can tell you english is very good Again thank you Sir for your help.
    When it comes to the diffriences in row 2 and 5 - in row 2 the number 27 should be black, and in row 5 number 37 should be black as well, because it doesn't fit the pattern that number 37 from the third row has created. Please remember the pattern consists of 5 Xs in the first row and 2 Xs in the second row and those 2 Xs have a free space inbetween them, that is why number 37 in row no. 5 should be black.
    Now what you Sir have undoubtedly achieved is to count the number of green Xs in each row. Congratulations for that

    JeteMC and menem If I may I would like to make an suggestion. In order to honor both of you Gentlemen for your help, I would like to propose to use a bit both of your solutions. In other words the "pattern solution" from JeteMC and the "counting of green Xs in a row" solution form menem. I believe integrating those two would make for a final solution to the thread
    Last edited by bansche123; 11-20-2019 at 08:36 AM.

  9. #9
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Making certain cells with an “X” turn green (complicated formula)

    I'm still confuse. >_<
    Please confirm.

    AA2 (27) is black because Y3-AC3 , Z4-AB4 are X , (It will be green if AA4 is not X ? )
    I3 (9) is green because match pattern G4-K4, H5, J5 are X and I5 is not X.

    Why W3 (23) is green ? while U4-Y4, V5-X5 are X ?
    (Same to W4, AA4, AB4, W5, X5)

    No doubt about V6, AB6, AK6 that's fit the pattern.

    Sorry to ask so much. T_T

    Regards.

  10. #10
    Registered User
    Join Date
    11-16-2019
    Location
    Liechtenstein, Vaduz
    MS-Off Ver
    365 MSO (64bit)
    Posts
    81

    Re: Making certain cells with an “X” turn green (complicated formula)

    AA2 (27) is black because it naturally must be, because the was no pattern before it since that is the first row. It is literally that simple. The first row is the starting point for the pattern so to say

    I3 is green since it matches the pattern from H2 (8)

    W3 (23) is green, because of the pattern created by W2 (23)
    W4 (23) is green, because it fits the pattern created by W3 (23) and so on.
    AA4 (27) is green, because of the pattern created by Z2 (26)
    AB4 (28) is green due to the pattern created by AA2 (27)
    W5 (23) even fits two patterns, one is from W4 (23) and the other one is from V4 (22)
    X5 (24) also fits two patterns, the first from W4 (23) and the second from V4 (22)

    I am more than happy to provide explanations, so please don't be sorry, I appreciate your dedication and help

  11. #11
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,535

    Re: Making certain cells with an “X” turn green (complicated formula)

    I would like to propose to use a bit both of your solutions. ...I believe integrating those two would make for a final solution to the thread
    Great idea! Please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. BTW this will not prevent you and menem from continuing your conversation in this thread. I hope that you have a blessed day.

  12. #12
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Making certain cells with an “X” turn green (complicated formula)

    JeteMc, slowdown please. I'm still confuse. >_<
    I need more time and will be appiciate if you or bansche123 give me some picture of
    GREEN / BLACK pattern.

    For me, win/loss pattern are look the same. >_<

    Regards.

  13. #13
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Making certain cells with an “X” turn green (complicated formula)

    I'm not sure is it correct. Please verify.

    For Condition format of I3

    Green :
    Please Login or Register  to view this content.
    Black :
    Please Login or Register  to view this content.
    For counting on AQ3
    Please Login or Register  to view this content.
    Press Ctrl-Shift-Enter for Array formula.

    Regards.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    11-16-2019
    Location
    Liechtenstein, Vaduz
    MS-Off Ver
    365 MSO (64bit)
    Posts
    81

    Re: Making certain cells with an “X” turn green (complicated formula)

    Thank you Sir, everything works perfectly, all the way it is supposed to be

  15. #15
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Making certain cells with an “X” turn green (complicated formula)

    I'm relief now. ^_^

    BTW, my condition format is not directly check on X mark , you may try by delete cell's formula (A2:AP8) away. :P

    Regards.

  16. #16
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Making certain cells with an “X” turn green (complicated formula)

    I just noticed that when I've copy condition format formula from I3 ( the orginal in creating formula ) it's refer reversed to row 1Ms.
    So, I need to insert for 2 rows above old table for maintain row reference as it should be.

    So the condition format formula of A4 ( Was A2 ) will changed to

    Black
    Please Login or Register  to view this content.
    Green
    Please Login or Register  to view this content.
    Regards>
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    11-16-2019
    Location
    Liechtenstein, Vaduz
    MS-Off Ver
    365 MSO (64bit)
    Posts
    81

    Re: Making certain cells with an “X” turn green (complicated formula)

    Unfortunately it dees not work. I made a new file with no formulas at all, maybe now it will be easier

    Please be advised, that I have added a new feature so to say with the "EXTRA NUMBER" ranging form 1 to 4. Now I would need the same formulas for that as well with a diffrient pattern however, but the pattern is really simple. Whenever no. 1 or no. 3 are picked the X goes under both of those numbers, and when np. 2 or no. 4 selected the X goes under them.
    Attached Files Attached Files
    Last edited by bansche123; 11-24-2019 at 02:57 PM.

  18. #18
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Making certain cells with an “X” turn green (complicated formula)

    May I ask ?

    Did in the NEW black contains an X ?
    And can you please tell me, why each NEW block is Black / Green.
    (I still can not understand English well, so explain for each cell maybe easier for me. >_<" )

    Regards.

    Ps. If I continue, I will continue from my file.

  19. #19
    Registered User
    Join Date
    11-16-2019
    Location
    Liechtenstein, Vaduz
    MS-Off Ver
    365 MSO (64bit)
    Posts
    81

    Re: Making certain cells with an “X” turn green (complicated formula)

    Thank you for the reply, so answearing all your questions in order:

    1.
    Did in the NEW black contains an X ?
    To be honest it does not really matter in the NEW case. If it will be easier to do without an X then here you go
    2.
    And can you please tell me, why each NEW block is Black / Green.
    Honestly I am sorry, but I am not sure what you mean by "block". Essentially the idea behind the extra number is the same as it was before with the 42 numbers. The differences are:

    1. 42 numbers changed to 35 numbers. Pattern stays the same, everything stayes the same, the only thing that changed is the amount of numbers.
    2. Extra number was added and here the general idea behind it is the same as in the 35 numbers, but there is a different pattern.

    Out of the 4 numbers only one number is chosen. The pattern looks like this: whenever number 1 or number 3 are picked then a X should appear beneath the 1 and the 3 in the next row - to give you an example:
    - in row 2 number 3 was selected (AO2) this means an X has to appear in AM3 and AO3

    Now, whenever number 2 or 4 are selected then the X has to appear below the 2 and the 4 - for example:
    - in row 5 number 4 was selected (AP5) this means an X has to appear in AN6 and AP6

    P.S. in the new file I only wanted to show what I mean by all of that. Of course, please feel free to continue in your file
    Last edited by bansche123; 11-26-2019 at 04:37 AM.

  20. #20
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Making certain cells with an “X” turn green (complicated formula)

    Formula in condition format in my file.

    AT4 : Black (Need to stop if true)
    Please Login or Register  to view this content.
    AT4 : Green
    Please Login or Register  to view this content.
    Regards.
    Attached Files Attached Files

  21. #21
    Registered User
    Join Date
    11-16-2019
    Location
    Liechtenstein, Vaduz
    MS-Off Ver
    365 MSO (64bit)
    Posts
    81

    Re: Making certain cells with an “X” turn green (complicated formula)

    Hi again I was trying to do the same thing that you have done, but this time for 50 numbers and 35 number only. I got the pattern with the Xs, but I don't know how to add the colours green and black to the pattern. May I kindly ask for your help? Also I have noticed that I cannot use the file you have created for the 42 numbers, because when I edit the formulas to fit 35 or 50 numbers for some reason it doesn't work that is why I would like to kindly ask you use both of my uploaded files here Thank you in advance
    Attached Files Attached Files
    Last edited by bansche123; 12-05-2019 at 06:18 PM.

  22. #22
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Making certain cells with an “X” turn green (complicated formula)

    All you need is adding 2 blank rows (yellow cells)


    Regards.
    Attached Files Attached Files

  23. #23
    Registered User
    Join Date
    11-16-2019
    Location
    Liechtenstein, Vaduz
    MS-Off Ver
    365 MSO (64bit)
    Posts
    81

    Re: Making certain cells with an “X” turn green (complicated formula)

    @menem

    Hello again Basically I have made a new pattern for a new file with 10 numbers and I was wondering if i could kindly ask you to help me out with the creating of the right formula?

    Pattern explanation:
    So, out of the 10 numbers, 2 are picked. From the first picked number like the 7 in G2 for the first pair of numbers in N2;O2, you go 3 cells to the left, so you arrive at D2, from which you go to the row below and make an X in the cell smaller by 1 and one X in the cell greater by 1 than D2 so you end up with an X in C3 and E3.
    That is it

    Note: when for example number 3 is picked like in N3, when you go 3 cells to the left it means that you end up in J3, and then you put one X in I4 and the second X in A4.

    You may wonder why some cells are red and the other ones are black. It is basically to tell apart the first selected number (red) and the second selected number (black). Obviously if a number is picked where before there was an "X" this cell shall turn green, just like in the previous cases. This also means that if the first picked number is an "X" you go three cells to the left from that green cell with an X (so it's not only red cells from which you go the 3 cells to the left, what matters is that it was the first picked number

    I would also need to have the total amount of green "Xs" counted in the K column

    I have filled out the entire table by hand to give you an illustration of what I am talking about. I also made the pattern a separate piece as shown in the attachment

    Thank you in advance
    Attached Images Attached Images
    Attached Files Attached Files

  24. #24
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Making certain cells with an “X” turn green (complicated formula)

    This is a first step, please verify X and color cells.
    Many are different , please tell me why.

    For example
    My I4,C5 are X and Green
    but your are only X. (Tell me that what I missed)

    or

    My I10 is X and Black
    but your is X and Green.


    Regards.
    Attached Files Attached Files

  25. #25
    Registered User
    Join Date
    11-16-2019
    Location
    Liechtenstein, Vaduz
    MS-Off Ver
    365 MSO (64bit)
    Posts
    81

    Re: Making certain cells with an “X” turn green (complicated formula)

    @menem Thank you for your help I wasn't responding, because for some reason my IP got blocked on the forum.

    I can seen that you got all the Xs right, so congratulations on that, that is a great start

    I4 is a 9, but in the numbers in that row there is no 9, there are numbers 7 and 8 so 9 should not be there at all. I don't know why it appears there green. What is right however is that there is the X.
    C5 is a 3, but in the numbers in that row there is no 3, there are numbers 6 and 7, so 3 should not be there at all, and here I don't know why it turns green.

    Now since you've got the Xs right, maybe it will be easier if you only work with black and green, and change the red also to black. The red was only there to tell which number is first in a given row.

+ 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. Making cells turn color when I insert a number in a cell
    By larzee1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-10-2018, 09:49 PM
  2. Turn off Error Checking (green triangle) for column A
    By jduong93 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-04-2017, 09:51 PM
  3. Lookup, rank, if x = 1 turn cell green
    By lstar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-25-2015, 09:37 AM
  4. How to turn certain cells green
    By sharkman1912 in forum Excel General
    Replies: 4
    Last Post: 07-13-2012, 06:12 PM
  5. turn red or green
    By devilonline in forum Excel General
    Replies: 2
    Last Post: 09-27-2011, 11:31 AM
  6. If all 3 cells say yes want next field to turn green
    By vanaaken in forum Excel General
    Replies: 6
    Last Post: 04-15-2008, 02:38 PM
  7. [SOLVED] turn off green triangles in Excel 2002?
    By Ron in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-19-2005, 10:06 AM

Tags for this Thread

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