Conditional formatting Excel results from cell, address functions - excel

I am using the cell, address, index, and match functions in Excel to return the address of the intersection of a row and column match. I can get the address correct using the following function, but I can't get it to format using conditional formatting with a formula.
=a2=CELL("address",INDEX(A2:E6,MATCH("g",A2:A6,0),MATCH("c",A2:E2,0)))
The data looks like this and the upper left corner is in cell A2.
a b c d
e 1 2 3 4
f 5 6 7 8
g 9 10 11 12
h 13 14 15 16
I want to enter a formula that colors the matching cell a certain color (the "11", in this example). How do I get this to work? If I just type =a2=$D$5 in the conditional formatting formula, it works, but I can't get it to work using the formula above.

Try following. I tested and got correct formatting.
=CELL("address",A2)=CELL("address",INDEX($A$2:$E$6,MATCH("g",$A$2:$A$6,0),MATCH("c",$A$2:$E$2,0)))
This will also work if there is no duplicate values in range.
=A2=INDIRECT(CELL("address",INDEX($A$2:$E$6,MATCH("g",$A$2:$A$6,0),MATCH("c",$A$2:$E$2,0))))
Another way to do that
=CELL("address",A2)=ADDRESS(MATCH("g",$A$1:$A$6,0),MATCH("c",$A$2:$E$2,0))

Related

Excel: Conditional formatting of whole row based on column value does not work

Suppose I have a simple dataset in Excel:
Column 1 Column 2
A 1
B 1
C 2
D 4
E 5
F 9
Now I want to mark the whole row with green color, if the value in column 2 is larger than 3. I apply a conditional format with the formula =$B2>3 applied on range =$A$1:$B$7 and it does not work:
One line where the value is 2 is marked green and one where it is 9 is not marked.
Now I want to mark the row, however only, if the value in column 2 is between 3 and 6. I apply the formula =AND(3<$B2;$B2<6) to the same range and it does not work:
Nothing is marked green.
Where is my mistake?
Update:
I now also tried =AND(3<$B1;$B1<6), but still nothing is marked green?
Change =$B2>3 to =$B1>3 which should work for you.
Your formula start range and apply start range must be same. Otherwise CF will highlight different cells.

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.

Input data into a 2nd cell, based on the value of a 3rd cell? (Like "conditional formatting")

B1 is a checkbox. If checked B1=1. A1 can range from 0 to 10. If B1 is checked I want A1 to automatically = 10. Exactly like conditional formatting would turn it green. I cant put the formula =IF(B1=1,10,"") into A1 though because I need to be able to input other values in A1 without erasing the formula. I need to be able to reuse the sheet multiple times.
Ex.
A B
1 10 x
2 9
3 10 x
4 4
As Scott commented, you'd need to use VBA to do exactly what you're asking. A work-around, though, would be to add a third column with:
=IF(B1="x",10,A1)
In this case, Column A would be the user-inputted number, Column B would be your "x", and Column C would give the final output: 10 if B has "x", and the number from A otherwise.

Populating Excel table using 2 cell coordinates - lots of data

I need your help with this problem I'm facing using Excel. Basically I need to populate a table, or better, a given group of cells (dimensions 3x3), and my starting point is:
row numb. column name. value
2 A 10
3 C 4
4 B 20
so I would need to obtain a group of cell like this:
1 A B C
2 10 0 0
3 0 0 4
4 0 20 0
where the cells that have no value can be 0 or whatever. In other words, I have the coordinates where I need to insert the value, and I need to be insert the value corresponding to the coordinates in the right cell.
I already tried many times using functions like MATCH, VLOOKUP and INDEX (also ROW and COLUMN) but without success, because it inserts the correct values but also other combinations of coordinates that I don't want.
My idea was to start from cell A2 and, with the formula, check if there's a match with the coordinates of row and column in the data, and finally print the value.
PS: I would prefer to avoid VBA.
Try this array formula: (Of course, change your cell ranges as necessary)
= IFERROR(INDEX($G$2:$G$4,MATCH(TRUE,ADDRESS(ROW(),COLUMN(),4)=($F$2:$F$4&$E$2:$E$4),0)),0)
Note this is an array formula, so you must press Ctrl+Shift+Enter rather than just Enter after typing the formula.
See working example below.

Shifting Bounds of an excel array by an arbitrary number of columns

I want to change the left bound of an array by an arbitrary amount of columns. for example i have the range A4:AA4. I want to shift the left bound of the array to D4:AA4. The number of columns that i shift the array by is arbitrary. So it could be D4:AA4, E4:AA4, F4:AA4 ...etc
I want to be able to do this in a formula, not through VBA. I want to use this range INSIDE a =MATCH() function. Could anyone help me out with this? thanks!
Not sure exactly what you are trying to accomplish here. Are you just looking for an absolute cell reference in your formulas? In case you are consider the following:
A B C
2 5 3
3 6
4 7
5 8
6 9
7 10
8 11
9 12
Column A contains the numbers 1 - 9
In B1 i type in the following formula =SUM(A1+$C$1) which i then autofilled until B8.
The dollar sign makes the both the column and row reference absolute and will not shift as part of the autofill.
If this is way of the mark so you have another way of explaining it or maybe included some sample data and desired output.

Resources