Conditional formatting in Excel based on formatted output in other table - excel

Say,I have 2 tables...Tables are related...
1 3 5 7
8 8 9 10
11 12 13 14
&
2 3 5 5
1 1 1 1
3 4 4 4
I have highlighted top 5 values in first table using conditional formatting rules.Now I want to highlight cells in the second table based on first table...Assume 11 12 13 14 7 10 are highlighted in first table....I want to highlight cells in second table occupied same position as of in highlighted cells in first table..i.e. 3 4 4 4 5 1 should be highlighted...How can I do that

Use Excel functions RANK and/or COUNTIF to calculate a sequential ranking list column for the first table. The expression is explained here.
For the second table, you can then use conditional formatting based on the computed rank.

Might just be an elaboration of #Axel's answer and I agree the details of the question do not make sense but the position of a selection of top (or bottom) ranked cells in one array (say A1:D3) can be used to determine whether or not to format a cell in the corresponding position of another array (say H5:K7):
Select from H5 to K7, then HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true::
=RANK(A1,$A$1:$D$3,)<6
Format..., select formatting, OK, OK.
Change the 6 to suit how many cells are to be formatted which for <6 could be more than five if the value ranked fifth is duplicated.

Related

Excel conditional formatting based on conditions

I am working on a personal project and have spent many hours researching colour formatting based on conditions. Unfortunately I have not been successful in achieving the end product.
I would be very grateful if anyone could help write a VBA code to address what I am trying to achieve below.
I have one named SaisieSO and two ranges. Range 1 (C:H) in which I enter six numbers and range 2 (N:R) in which I enter 5 numbers.
I would like in the worksheet in the Range (C: H) the cells to change colour based on the following conditions:
any cell in range (C:H) to be coloured red with white font if their value is equal to the value in N
any cell in range (C:H) to be coloured orange with black font if their value is equal to the value in O
any cell in range (C:H) to be coloured yellow with black font if their value is equal to the value in P
any cell in range (C:H) to be coloured blue with black font if their value is equal to the value in Q
any cell in range (C:H) to be coloured orange with black font if their value is equal to the value in R
I would like each time I add a new row with numbers in both ranges for the VBA code to colour the relevant cells as stipulated above.
Example
Range (C:H) six numbers Range (N:R) 5 numbers
Dates
C D E F G H N O P Q R
02/08/2019 16 14 11 5 15 7 4 8 6 3 7
07/08/2019 12 6 2 14 1 5 12 6 15 5 13
08/08/2019 14 10 7 6 13 8 14 10 12 7 9
09/08/2019 8 16 6 10 7 2 7 16 2 8 4
I hope you are able to provide me an answer
Many thanks in advance
Bruno
I'm advising you not to use VBA, but to do this using conditional formatting, the basic feature of Excel, as explained in this URL.
You can simply write a formula, and when this formula gives "TRUE", then the conditional formatting will be applied.
E.g. in cell C2 I've put a value, and in cell N2 I've put the same one. I've then created a conditional formatting rule, based on this formula:
=(C2=$N2)
When C2 equals N2 the result of this formula yields "TRUE", so the conditional formatting will be applied.
Why the dollarsign in front of column N? Well, you seem to want to use conditional formatting for the range C:H. When you drag to the right (e.g. for column D), your formula changes into:
=(D2=$N2)
As you see, dragging to the right changes your column reference from C to D, but the N is left fixed, because of the dollar sign. This is known as absolute cell referencing, and is explained here.

How to create two columns that match all values from a third in excel or OpenOffice?

I have one column with 10 cells, every cell have a different value in it. How can I create two columns that have every cell matching with the other 9.
Example :
1
2
3
4
5
6
7
8
9
10
Become
1 2
1 3
1 4
1 5
......
2 1
2 3
2 4
2 5
.....
10 1
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9
I am not sure I read the same question as others did. I think your example was merely that, an example, and that these first 10 cells could contain anything and you wanted every permutation that could result. While I think that the other answers might work for the specific situation you describe, they may not work if you had other data in those cells. Hence I am offering a variation which uses a similar technique to reference the cells indirectly. The permutations of 2 objects from a set of 10 unique objects would result in 90 objects (which is why the above technique from Tom Sharpe references 90).
Assuming that you have your 10 items in A1 through A10, I would put the following formula in B1 and copy it down through B90:
=INDIRECT("R"&QUOTIENT(ROW()-1,9)+1&"C1",FALSE)
Also, I would use this formula in C1 and copy it down through C90:
=INDIRECT("R"&MOD(ROW()-1,9)+1+((MOD(ROW()-1,9)+1)>=QUOTIENT(ROW()-1,9)+1)&"C1",FALSE)
The result should give you something like what is shown in the attached matching your example.
Likewise, it would show the permutations of any values you had in A1 through A10 as shown in the second attached picture with words instead of the numbers 1 through 10.
In Excel (without VBA or such like), one way:
In A1 and copied down to A100: =INT((ROW()+9)/10).
In B1 and copied down with Ctr to B10: 1.
Select B1:B10 and copy down with Ctrl to B100.
In C1 and copied down to C100: =A1=B1.
Select ColumnsA:B, Copy, Paste Special, Values.
Filter A:C ,select TRUE in ColumnC and delete all blue indexed (visible content) rows.
Delete ColumnC.
Or in A1:
=QUOTIENT(ROW()-1,9)+1
copied down to A90 just to be different.
Then in B1:
=MOD(ROW()-1,9)+1+((MOD(ROW()-1,9)+1)>=A1)
copied down to B90.

Replacing value with ID if matching another value

I have three columns:
A B C
1 TextOne TextOne 10
2 TextOne TextTwo 11
3 TextTwo
4 TextTwo
5 TextOne
6 TextTwo
Applying the formula below I was expecting the result 10:
=IF(ISNA(VLOOKUP(A1,$B$1:$C$2,2,FALSE)),"0",VLOOKUP(A1,$B$1:$C$2,2,FALSE))
but I am seeing NA and suspect this is connected with the format of the cells.
Where am I going wrong?
The issue was initially caused because I was trying to replace the value in cell applying the formula in the same cell.
As #datooo points in his comments:
Once the formula is entered the value you are looking up is gone
To ‘overwrite’ TextOne with 10 the simplest solution may be to filter ColumnA to select TextOne, enter 10 and copy down (change filter selection and repeat for TextTwo / 11 if required).
For a 'high volume' requirement (lots of replacements) use VLOOKUP (eg as in question) in a separate column and copy that column's results over the top of ColumnA with Paste Special Values.

Highlight duplicate cell values in different colours

I'm using conditional formatting to highlight duplicate cells, but I have up to 5 instances of a duplicated value. How can I apply a separate colour to each duplicated cell?
So if I have 5 instances of ABC123, how can the first instance be red, the second green, the third blue, fourth yellow, fifth orange (or whatever colours)?
I take it this is in Excel 2007? In earlier versions you can only have three different conditions.
The way I'd do this is to introduce a 'helper' column, containing a formula which provides the count of duplicates up to that row number:
Say you have your list (including dupes) in range A1:A10, and in column B1:B10, a formula of the form =COUNTIF($A$1:A1,A1) through =COUNTIF($A$1:A10,A10), you'd have
A B
------------
1 4 1
2 2 1
3 4 2
4 3 1
5 1 1
6 2 2
7 4 3
8 2 3
9 2 4
10 1 2
I don't know your exact Conditional Formatting requirements, but you can now use 5 nested IF formulas to take account of not only the fact that something is a dupe (cell in B is >= 2), but also the count of the dupe.

How to auto format a table in Excel?

I have a table in Excel. In each row, I want to highlight the columns that correspond to the maximum value in that row.
For example, if I have this table:
0 1 2 3
4 5 3 5
8 9 3 4
I want to highlight 3 in row 1, 5 in row 2 and 9 in row 3.
How can I do that automatically?
THANKS!
In Excel 2008, you can use Conditional Formatting in the Styles section of the Home Tab. Choose "Highlight Cells Rule", then "More Rules...". That opens the "New Formating Rule" dialog. Choose "Format only top or bottom ranked values". Then choose Format values that rank in the "Top" 1 and leave the % of selected range box UNchecked. Then click the Format button to pick the format that you want.
If you want to be able to do this fully automatically, what you can do is record a macro that does the actions described above and use that to repeat for all rows of your table.
I think you could do this with conditional formatting, and you wouldn't require code. Just create a formula that looks to see if the cell value is equal to MAX(range_name) and highlight the cell in whatever way you choose.
This is somewhat roundabout, but works for me. Add an extra column (E) somewhere, so you end up with this for data:
A B C D E
1 0 1 2 3 =MAXA(A1:D1)
2 4 5 3 5 =MAXA(A2:D2)
3 8 9 3 4 =MAXA(A3:D3)
Then in a cell, add a conditional format:
For A1: =IF(A1 = $E$1, 1, 0)
Use the format painter to copy this to the other cells in the row. Then copy to the column, modify each column so the $E$1 reference is corrected, and copy to those rose as well
Ugly, but gets the job done. Probably a quicker way to do it with VBA.

Resources