How to count conditional formatted cell colors across a row - colors

I have 5 cells that are conditional formatted. Column B is CF for 48 months and turns red on 48 months and 1 day, Column C is for 36 months, Column D is for 24 months, Column E is for 18 months, and Column F is for 12 months.
I would like to be able to use a count color formula to count the green color cells across the row (i.e., B1:F1) and place the result in H1. I have tried to use every VBA I could find but none of them work. For Example, when I use a COUNTConditionColorCells Function, it produces different number sequences next to the cell range box (see attachment) Thanks
Sample Worksheet
Function Argument

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.

Dragging formulas across - Increment columns by more than 1

I can't seem to find anything similar that's already been asked (they all relate to incrementing row numbers rather than columns)
I'm looking to drag a formula across horizontally and have the columns increment by 2
E.g. B1-A1, D1-C1, F1-E1...
Thanks!
You'll need to have a value in cell A1 and B1 for the following to work.
For my testing I put the number 1 in A1 and B1.
Try this in Cell C1:
=IF(MOD(COUNT($A$1:B1),2)=0,COLUMN(B1),IF(B1<>A1,B1,A1))
Here's what you should see when you drag that formula across:
A B C D E F G H I J K L M N
1 1 2 2 4 4 6 6 8 8 10 10 12 12
And this is what the formula does:
The MOD(COUNT() part of the formula counts the cells to the left of it, and if they are a multiple of 2, the value changes.
I've left the value to change to (the 'new' value) as the COLUMN() number for the cell before, just for example's sake. but you can change this part.
The last IF statement at the end checks if the cell before is equal to the cell before that, (eg. Is CELL C1 equal to CELL B1) and if they are not equal, it will give the cell before as a value (the 'copy' value).

Excel horizontal list to columns

I am looking to format some data. To make it more easy I use an example with simple numbers.
Sheet 1 ('S1'):
A1 10
A2 14
A3 23
A4 12
A5 64
A6 32
.... etc
It is a long list(vertical) of 600 values
Now I want in Sheet 2('S2'):
To show it as:
S1!A1 S1!A2 S1!A3 S1!A4 S1!A5 S1!A6
S1!A7 S1!A8 S1!A9 S1!A10 S1!A11 S1!A12
S1!A13 S1!A14 S1!A15 S1!A16 S1!A17 S1!A18
References to the cells in the other sheet.
I have tried to transpose them but I cannot find a modifier to set an amount of columns used. i.e. I would get 1 row with all my data. I want only the first 6 in row, next 6 in next row, next 6... etc.
Thanks for any help/feedback given.
Put this in the upper left cell desired:
=INDEX(Sheet1!$A:$A,(ROW(1:1)-1)*6+COLUMN(A:A))
Then copy/drag over 6 columns and down till you finish the list
Sheet1

Sum row in Excel/Google Sheets based on Condition

It seems like this question should exist somewhere, but I can't seem to find it...exactly.
The most similar solution I can find requires the use of SUMIFS or SUMIF, which only seems to add up numbers in a column, not spanning multiple columns. Here's an example sheet with 2 rows:
A B C D E F G H ...
1 2015-01-01 0 1 6 12 45 12 5 ...
2 2016-01-01 256 43 13 35 134 135 12 ...
Now I'd like to have a cell somewhere that adds all of the cells in the row for 2015-01-01. My attempt looks like:
SUMIF(A1:A30,"2015-01-01", B1:BJ30)
But this only yields the sum of the column B, so 0 for the exact formula above or 256 if I were to do this for the year 2016.
When trying something with SUMIFS, I'm told that the criterion range's size should match the sum range size, which isn't the case because my criterion range is only the first column of dates.
How can I add all the values in a row if the first cell's date matches my criterion? It may be worthwhile to note that this is in Google Sheets, not Excel.
In both excel and googlesheets you can use a SUMPRODUCT, for example:
=SUMPRODUCT((A1:A30 = DATE(2015, 1, 1)) * B1:BJ30)
You can try either of these:
=if(A1=date(2015,1,1),sum(B1:F1),"")
=if(A1=A1,sum(B1:F1),"")

Resources