This tutorial explains how to use Excel formulas to format cells and entire rows based on the values you specify or based on another cell's value, and provides a handful of formula examples. Continue reading
by Svetlana Cheusheva, updated on
This tutorial explains how to use Excel formulas to format cells and entire rows based on the values you specify or based on another cell's value, and provides a handful of formula examples. Continue reading
Comments page 46. Total comments: 1726
Dear Svetlana,
I want to use formula or conditional formatting for below mentioned condition:
If i enter a date in one cell of column A and missed to enter some data in other cell of column B then color of cell of column B need to appear Red, and vice versa...
Please reply ...
Little Urgents..
Regards
Shubham
Hello Shubham,
You can create two rules as follows (assuming that row 2 is your first row with data):
For column A: =AND($B2<>"",$A2="")
For column B: =AND($A2><"", $B2="")
Hi Svetlana,
Suggested formula works .....Thanks a lot.
Could you please explain the logic behind as i have tried similar things but didn't succeeded earlier...
Thanks a lot for the solution, you deserve a treat from my side..:-)
Shubham,
I will try. The logic is actually pretty simple : )
For column A:
- You use the AND function to set 2 conditions.
- Condition 1 - a cell in column B is not empty: $B2<>"" (<> means "is not equal to", "" - no value)
- Condition 2 - a cell in column A is empty: $A2=""
The rule for column B is analogous.
An absolute column reference ($A - with the dollar sign) and relative row reference (2- w/o the dollar sign) tell Excel to adjust the formula for each individual row.
Hope this makes sense.
Hi Svetlana,
I am trying to get cells in a column to equal a value of 1 with numbers in the cells that could be 1-50,but the value of each cell still is counted as 1 so that I can get them to sum up at the end. Thanks.
Hi Bobby,
If my understanding is correct, you need to count the cells in a certain column with values from 1 to 50, inclusive.
If so, I can see 2 possible ways:
1. Use the following COUNIFS formula:
=COUNTIFS(A1:A10,">=1", A1:A10,"<=50")
Where A1:A10 is your range of cells.
2. Add a helper column with the following formula next to your column with numbers:
=IF($A1>=1,IF($A1<=50,1,""),"")
It will populate a cell in the helper column with "1" if a cell in the same row in column A is between 1 and 50. Then simply use Excel's AutoSum to count 1's.
Hi Svetlana,
I am trying to have any cells in Column Q that have an equal value as any cells in Columns A and B be formatted; with the values in Columns A and B continuously changing. I've only been able to input a successful formula that highlights equal values that are only within the same row. Thanks.
Svetlana,
Is there a way to make the color associated with a conditional formatting rule dynamic?
For example can I feed a value in cell A, a color in cell B, and make the conditional formatting formula's 'format' in cell C depend on the value of A but if true to present the background color indicated in B?
Thanks!
Hi Susan...Hopefully this isnt something that Ive missed, but I am needing advice.
I am using conditional fomatting to format an entire row if column G contains a conveying document type (eg. WD, TD..)
I higlighted the table, used:
=$G1="WD"
It worked great!!
My question is, I want it to be the same color for WD, TD, Exec Deed,...etc. Is there a way to have all these words in one rule? Or do I have to make a new rule for each word?
Thanks!!
Hi!
Of course, you can have them all in one rule by using the OR formula like this:
=OR($G1="WD",$G1="TD",$G1="Exec Deed")
Awesome thread, thanks a lot! Even though I didn't ask a question, my doubt got solved :)
I have duplicate values in Column B, and I would like to have the entire rows highlighted when a duplicate value is found in Column B only. Similar values may also be found in Column A, but I only want the duplicates from Column B to be considered when highlighting the entire row. How would I accomplish this? Thank you!
Hello Susan,
Simply select all the columns and create a rule using this formula:
=countif($B:$B,$B2)>1
Perfect - thank you SO MUCH! Have a great day!
I am trying to conditionally format an entire column based on the information from another column. For example, I want to highlight red in B1 a value less than that of A1. It will be green when greater than A1. I also want to highlight red in B2 when it is less than A2, green when greater than. So each value in column B needs to be highlighted with its corresponding A value. I just do not want to have to do this line by line for 50 items. Is there a way to do this all at once?
Hello Woody,
Of course, there is no need to create a rule for each row. You simply select all the cells in column B that you want to highlight, say B1:B50, and create 2 rules with the following formulas:
Red: $B1<$A1
Geeen: $B1>$A1
Since you use the absolute column (with $) but relative row (w/o $) references, Excel will adapt the formulas for each indibidual row and highlight cells in column B as you need.
My query is on conditional formatting with dates.
I have a spread sheet which has the following columns:
1. Todays date $B$1
2. Date entered for return of document $AJ4 lets say 3/10/2014
If column 2 has the date 3/10/2014 then highlight 30 days prior in red.
Thanks
Hello Jean,
I am sorry, it is not very clear how column 2 and $AJ4 are related. If you can send a sample workbook to support@ablebits.com, we will try to help.
This blog has been very informative, but I have not found an example of my problem yet. I simply want to highlight duplicates (preferably not the first occurrence) only when the values in two other columns match. In other words, I would like to find duplicates in column C only when the values in columns A and B are the same.
I've tried countifs formulas, but they are not working. I wonder if I need to use a match statement or something similar. Any advice would be greatly appreciated.
Many thanks.
I read over my comment and realized that it may be unclear that I want values WITHIN columns A and B to match, not match each other (for which I found an example). For example, duplicates would be highlighted in column C when values in column A = 1 and values in column B = 2, then duplicate searching would start new when values in either column A or B change.
Thanks again.
So, I have been continuing to work on this problem and I have the correct formula to highlight duplicates in a column if values within 2 other columns match. For example...
=COUNTIFS($B:$B,$B2,$E:$E,$E2,$J:$J,$J2)>1
However, I am having a hard time to avoid highlighting the first instance in this case with multiple columns.
I would also like to have a separate column that has a formula resulting in a "0" value when it is the first or only instance of a value in column J, only when the values within B and E columns match. Right now, based on something I found that explains how to do this in one column, I've tried to modify to include multiple columns like this formula...
=IF(COUNTIFS($B:$B,$B2,$E:$E,$E2,$J:$J,$J2)>1,0,NOT(COUNTIF($J$2:J2,J2)=1)),but I don't think it is dealing with the multiple columns well.
Again, advice on this would be appreciated.
Thanks!
Raineek,
I'm not sure I can completely follow you. If you need to highlight duplicates rows by comparing rows by several columns and highlight only the second and further occurrences, this can be dome using VBA or our Duplicate Remover add-in. Sorry, I don’t know a way to do this using Excel formulas.
Hello Raineek,
If my understanding is correct, you want to highlight C3 if any of the above cells contain the same value and if A3 is equal to B3.
If so, select the column C starting from C2 till the end of the table and enter this formula:
=AND($A2=$B2,COUNTIF($C$2:$C2,$C2)>1)
So I am creating my own budget sheet for uni, and I have almost done it. I am just stuck with one problem.
Based on my grant, I have £11.52 a day on average. This is £80.64 a month. To make sure I don't overspend (as we get a lump slum every 3 months) I am basing the budget on a day to day format.
My problem is, Say I spend £10 on the first day, this leaves £1.52. This money can then be split over the 6 other days meaning I would have £11.77. However, I can not find a formula that will allow me to do this. Say I spent £6.00 on my first day of the week. I would then have £12.10 for the other 6 days. Then if I continued to under spend, My daily budget would increase.
It currently looks like:
Date Daily Amount Spent
02 October 2014 £11.52 £0.00
03 October 2014 £11.52 £0.00
04 October 2014 £11.52 £0.00
05 October 2014 £11.52 £0.00
06 October 2014 £11.52 £0.00
07 October 2014 £11.52 £0.00
08 October 2014 £11.52 £0.00
Total Left £80.64 £0.00
Any answers anyone
Hello Adam,
You can deduct actual expenses from the weekly budget, then divide by the number of remaining days and you'll get your budget for a day. If you send your sample workbook at support@ablebits.com, I believe we'll be able to write a proper formula.
kept looking and found the answer on another site:
Highlight the entire area (all columns and rows with data); manage rules; create new rule, where A1 is first cell and O is last column:
=A1>=LARGE($A1:$O1,3)
Perfect! :)
Very nice blog!
I have a list (top to bottom) of let's say 100 customers, and their monthly sales (so Jan-Dec, right to left).
For each customer (ie, each line) I want to use Conditional Formatting to highlight each customer's best 3 months.
I can certainly do conditional formatting on each of the 100 lines, one by one, but that is extremely burdensome. Is there some way to highlight all 100 lines and all 12 months and have excel know to do it line by line and not just pick the three best results out of the whole range (1,200 cells)?
Thank you VERY MUCH!
Helo,
Again I want to ask for your help...
I have spread sheet and I need a sum up.just like this
if value in column A was duplicated the value in column B and C in that row will automatically sum up.
Thank you
Hello,
Good morning,I already figure it out last night.
Thank you very much
Hi Svetlana,
THANK YOU very much
It's really a BIG help for me...
And if column B is appreciated column D will be the same date as column C.
Thank you
Glenn
Hi Glenn,
Here is the formula for cell D1:
=IF(B1="Appreciated",C1,"")
Hi, Good morning
Can you please help me with my formatting problem.
I have an work sheet with several column. I need to format a column based on the other column. eg; column B will be Appreciated IF column A says Positive Behaviour.
Thanks in advance
Glenn
Hello Glenn,
Conditional formatting is not needed for this task. Simply put the following formula in cell B1 and then copy it down column B:
=IF(A1="Positive Behaviour","Appreciated","")
If your data starts, say, in row 2, then replace A1 with A2 and copy the formula in B2.
Thanks. This tutorial is brilliant. I used it to color my bank statement xls. It helps identify the Debit and Credit transactions in just a glance.
=$D13="DR"
Color Red for
=$E$13:$E$50
Wonderful tutorial!! Thank you so much!!
Hi Svetlana,
Could you please help with the below conditional formatting
I have a product (orange)
I have Stock on Hand (SOH)of 95Kg (CellD2) and I have and order for today of 45Kg (F2)and tomorrow 40Kg (G2).
Then I have a stock on order (SOO) of 100Kg (E2)
What I need is:
Highlight my orders in yellow when my SOH cover the QTY ordered then
Highlight my orders in red when my SOO cover the rest of my orders
Ultimately no highlighted cells if SOH and SOO doesn't cover my orders
Below example:
The 95Kg of SOH cover 24 and 25 of September with 10Kg left over
With my SOO of 100Kg plus the 10 left from SOH, (110Kg)cover the 26 but not the 27
Therefore (24 and 25) should be yellow, 26 should be red, 27 no highlight
Can you help
DC Article Description SOH SOO 24/9 25/9 26/9 27/9
656 369558 Oranges 95 100 45 40 56 75
Hello Michael,
You can use the following formula to create the "yellow" rule:
=SUM($F2:F2)<=$D$2
Also, make sure the "Stop if true" checkbox is selected for the "Yellow" rule in the rules' list.
The "red" rule should look as follows:
=SUM($F2:F2)<=($D2+$E2)
Hi Svetlana,
I have a question related to the similar topic. Would you be able to advise if a cell can be formatted/ formulated based on the value of a range of data in a row?
E.g. A row of data has been conditioned formatted to highlight the highest numerical value as bold blue while the rest which are not the highest numbers are in default black colour.
In a separate cell, if I were to key in the highest value or other value, can the cell be formatted to show what is exactly in the range of data which was conditioned formatted earlier?
Thanks a million!
I would like to use conditional formatting for multiple cells based on date. There are pending, completed and "blank" cells. I also need to create a tally based on the updated cells by location (I was thinking i could link the cell to a certain area within the sheet or even create a new sheet. I have six locations and I want to have the table "updated" automatically once a milestone has been completed? How can I do all of this for one sheet?
Thank you! I need all the help i can get.
I wanted to utilize conditional formatting to highlight cells that are 90 days away from a certain date. Then if it passes that certain date to become red. Can someone please help?
Hi there,
thank you for the great text. i recently downloaded an spreadsheet from excel built-in template called "Gantt project planner". I was wondering have you seen that file, I couldn't figure out how it used special formatting. If you can't find it. please let me know to explain more. anyway, I copied them in the following,
Actual =(PeriodInActual*(project!$E14>0))*PeriodInPlan
ActualBeyond =PeriodInActual*(project!$E15>0)
PercentComplete =PercentCompleteBeyond*PeriodInPlan
PercentCompleteBeyond =(project!BY$8=MEDIAN(project!BY$8,project!$E17,project!$E17+project!$F17)*(project!$E17>0))*((project!BY$80)
PeriodInActual =project!BY$8=MEDIAN(project!BY$8,project!$E19,project!$E19+project!$F19-1)
PeriodInPlan =project!BY$8=MEDIAN(project!BY$8,project!$C20,project!$C20+project!$D20-1)
Thank you very much if let me know how these formulas work for conditional formatting.
i used coding in java, Excel - Using formula(String formula = "SUM(Vouchers!E2 : Vouchers!E"+(rec+1)+")";) to reference values on other sheets(Vouchers) get 0 only, i directly apply this formula in excel sheet, got 86123.67, but reference to other sheet got answer of #Value, why this happen?
HI madaam,
I want to create formula that when I input letter on a cell, ex. L on b5 then
b6 will have letter v.
Hi Svetlana,
Great and very informative post.
In a large range A1:AK100, I need to highlight the first cell (A:A)in a row if ALL cells in the rest of the row are blanks. Please note that all cells contain formulas that either return a value or "".
Thanks
My query is on conditional formatting with dates.
I have a s/s which has the following columns:
1. Date Contract sent out
2. Date Signed contract returned (blank until it is returned)
3. 7 days reminder
4. 14 day reminder
5. 21 day reminder
If column 2 is blank, the highlight (I have this part done)
If column 2 is blank and 7 days have elapsed since date in column 1 then format cell green
If column 2 is blank and 14 days have elapsed since date in column 1 then format cell orange
If column 2 is blank and 21 days have elapsed since date in column 1 then format cell red
Thanks
Hi All,
I have two cells data as
A10 : if(a = b)
B10 : if((a = b) && (b = c))
I want the cell C10 to be
c10: if((a = b) && (b = c)), the extra chaecters are to be displayed in Bold RED colour.
Please help
A B C
149 86 554
if less than value is 86 then who can we highlight B in another cell
may i know how to do it
i want to do conditional formatting based on another cell value.
for ex:
if cell(A6)= N, the formate of c8:p20 should be defined format,
like that for different value of a6 the formate of c8:p20(defined formate) should change
Hi,
i want to know is there any formula to get freez (desire)coloum i.e.
like if A1=1 than any one able to enter the value or text on G1
if A1=0 than no one able to enter value or text on G1
kindly help if you know
Hello Arun,
I am sorry, I don't know the way to fulfill this task using conditional formatting, a special macro is needed for this.
Hi,
Thanks a lots for your reply
is there any reference for same?
if yes than kindly share with me
hi, i'm looking for a formula to highlight cells in a pivot if cell value is >= 20 and at least 4 consecutive cells. help! thank you.
Hello Shawna,
Please have look at this article about using conditional formatting in PivotTables:
https://www.ablebits.com/office-addins-blog/excel-pivot-table-tutorial/
If you need to highlight cells with the value greater than 20 and if the values of the three preceding cells are greater than 20 as well, then select all the data (they should be in the 4th row or below) and enter this formula:
=AND($B5>=20,$B4>=20,$B3>=20,$B2>=20)=true
Where B is the column with your data, B5 is the first cell with the data.
I am trying to highlight duplicate rows only where the duplicated information is on a consecutive row. The duplicated information is a text field -- two letter state abbreviations. Any ideas how to do this with a text field?
Hi Sherry and Crosbi,
Recently we've received several such questions and I thought we should add an example to the tutorial. Please check it out:
How to highlight consecutive duplicates in Excel
Hopefully this is the solution you are looking for.
I'm trying to setup conditional formatting as follows:
Say Column A are dates that deliveries were scheduled e.g. 08/27/2014
I want the conditional format of Column B to show just the scheduled month and year; for example the date in cell A1 (08/27/2014) should appear as Aug-14 in cell B1.
Can someone provide the type of conditional formatting I should apply to Column B so that no matter the date in Column A, Column B will show that Month and year??
I creating a macros and this is the final piece to the puzzle. Please and thank you in advance!
- Lacy
Hi Lacy,
I think conditional format is not needed for this task. You can enter the formula =A1 in B1, then copy it across the entire column B, and then set the format mmm-yy for column B (Format cells > Number > Custom).
Hi Adam,
Simply select the range A3:I8 and create the rule with this formula: =$B$3=""
I am having an issue with Conditional Formatting. What I have is A3:I8 and I want to fill in all cells when cell B3 is blank. I have tried everything I can think of and nothing has worked. What would be the best way to accomplish this task?
Hi svetlana! well thanks it was really worked it out.
Hmmm...well svetlana can u tell me plz frm where i can learn advance Excel and VBA through online ??? so i can check the solutions by my self...??
Thanks 1nce again..
Is it possible to highlight only duplicate rows that are consecutive in order? Only duplicates on consecutive rows need to be highlighted. The field that is being compared is a text field -- a name.
Thanks for any direction you can give me.
Hi Sherry,
You can highlight consecutive dupes by creating a rule in this way:
- Select the column where you want to highlight duplicates, without the column header.
- Create a conditional formatting rule using this formula:
=$A1=$A2
Where A is the column with your data, $A1 - the column header, and $A2 – the first cell with data.
Hi Excel Gurus,
I want do following please help me how do I do this.
I have set of samples taken which about 300000 samples in a column.Now I want to calculate average of every 1000 samples.
Please help me how to do this calculationin EXCEL.
--Sameer
Hi svetlana!
i m having problem in excel regarding below
assume i have a value which is 10 in cell A1 and 20 cell B1 so i want to calculate these 2 columns or in result i want answer value with Text include by single formula.
Suppose if i calculate through if condition e.g If(A1>B1,"increased by"A1-B1,"decressed by"A1-B1))
the answer should be like this ( Decreased by 5 )/(Increased by (value))
can u plz help me out of this??
i hope u`ll understand what mean 2 say??
Hi!
You were almost there : )
=IF(A1>B1,"Increased by "&(A1-B1),"Decressed by "&(B1-A1))
Hello Sameer,
Try pasting this formula in any cell of the second row:
=AVERAGE(INDIRECT("A"&((ROW()-2)*10000+1)&":A"&(ROW()-1)*10000))
Where A is your column with the data; -2 is the row number with the minus sign. Then copy the formula down to 30 cells.
I have a similar problem that is not listed under your manual. I'm doing a sales analysis from period to period and I need to be able to tell when sales for a certian product either drop or go up by 15% all the sales figures are entered in percents as well.
Hi Bradley,
I am sorry, I can't make a proper formula without seeing your data. If possible, please send a sample workbook at support@ablebits.com and we'll try to help.
I found the reason my conditional formatting formula didn't work is that I used a lower case letter for the row label rather than upper case.
Can I ask a question – trying to format a pivot table and highlight the last column where the value is under the avg – eg 57709 is below para – please highlight the “4”
Do you know any other way ? other than manually
Mark
57703 21 34 36 31 38 34 33 27 29 44 30 29 29 415
57709 4 5 2 6 2 2 4 1 5 180 4 215 21.1 4 -17.1
57712 25 20 21 23 28 32 25 17 30 17 27 24 28 317
57715 9 8 16 7 15 16 7 11 13 9 113 12 20 256 19.66667 20 0.333333
57901 1 1 1 2 3 1 3 2 2 1 1 5 2 25
Hi Mark,
I am sorry, I don't know a way to fulfill this task using conditional formatting formulas.
Not sure if this can be done and I've tried a bunch of different ways to create a rule and keep coming up short. On my X axis I am using names. I know which names need to be in different colors. I cant seem to come up with the proper formula or rule to make this happen.The y axis which relates to $ has nothing to do with what I need the x axis to do so writing a rule to that end wont work. Any suggestions?
Hi Nique,
Did you try selecting the entire table and creating a rule similar with the below formula?
=A2="name" (where A2 is the left-most cell of the applied range)
If this is not the result you are looking for, please send me a sample workbook at support@ablebits.com and include the result you want to get.
Hi Svetlana,
I am trying to set up conditional formatting rules to evaluate the following excel spreadsheet.
Actual value column to a Budget column value. Based on the Actual value column if it is 10% or less from budget value color yellow, if greater than 10% color red and if monthly value is equal to budget color green. I have set up 3 rules with Use formula to determine which cell to format, but it not doing what I want it to do?
Examples:
Rule 1 B5=C5 format green
Rule 2 B5>C5*.10 Format Red
I have tried using $B5 or $B$5 same results,
any suggestions in accomplishing this task so I can have the color's automatically filled in? Thank you!
Hi Shannon,
The rule with $B5 should work, assuming that row 5 is the first row in the applied range.
If it still does not, please verify the following:
- Make sure you entered the correct column names (B & C)
- Probably, the Green rule shall be applied when a monthly value is equal or _less than_ a budget: =$B5<=$C5
- In the Yellow & Red rules, you should multiply by 1.1, not by 0.1. (Red: =$B5>=$C5*1.1)
- Check if your numbers are formatted as numbers and not as text (they should be aligned to the right, without a green triangle in the top-left corner of the cells)
If none of the above suggestions work, please send me a sample workbook to support@ablebits.com and I will try to help.
Hi
I'm trying to setup a conditional formatting with the icon sets and I need some help!
I've this situation:
B C D E
A1 Sell to 20 L
A2 Buy From 25
A3 Sell to 30 M
A4 Buy From 5
A5 Sell to 15 H
A6 Buy From 2
I've setup a conditional formatting check for A1B1 that says if there's an N,L,M,H change to appropriate color (easy!)
However in the A2B1 (and in every other cells) there's a number that I'd like to have compared to the every other cells that refers to the rows "Buy From" using the icon sets (bars value)
Is there a way to do this without manually select every other cells and apply the conditional check?
Also, once I've created the conditional formatting(s) for the column B1, can I copy paste its properties to the other columns by dragging the source column in my worksheet.
I hope I've explained my problem :-)
Hi Antoine,
Sure, you can apply your rule to other columns. Go to Conditional Formatting > Manage rules, and change the range in the box under "Applies to".
As for the icon sets, it is difficult to understand what data you have in the columns without formatting. Please send us your sample workbook to support@ablebits.com and we will try to help.
Hi
I'm trying to create a conditional formatting rule, but nothing seems to be working, could you help.
If cell Z3 is equal to or greater than 25 I want cell C3 to be green, if Z3 is between 15 and 24 inclusive I want cell C3 to be orange, if Z3 is equal to or less than 14 I want cell C3 to be red.
I've managed to get simpler conditional formatting rules to work, but when I've gone to copy for the formula into other rows it wont work.
Any suggestions please?
Hello Emma,
Most likely, the problem is in using proper absolute / relative cell references in the formulas. You can find more information about different cell references types in this article: Relative and absolute cell references in conditional formatting rules.
If you need to compare values in each individual row, select all the rows you want to format and create 3 rules with the following formulas (assuming that row 3 is the first row where the formatting is applied):
Green: =$Z3>25
Orange: =AND($Z3>=15, $Z3<=24)
Red: =$Z3<=14
In case you want to format all the rows based on the value in cell Z3, use absolute cell references in the above formulas, i.e. $Z$3:
Green: =$Z$3>25
etc.
Hi
I am trying to highlight duplicate data in 1 column only if they data in the next column are also duplicated. How do I do that?
Thanks
Hi!
You will need to insert a helper column. Suppose, the original columns are A and B, and column H is the helper column.
- Type =A2&B2 into the cell H2 and copy the formula down column H.
- Select columns A & B and create the conditional formatting rule to highlight duplicates with this formula:
=COUNTIF($H$2:$H$100,$H2)>1
As an alternative, you can also use our Duplicate Remover add-in (the Color duplicates option) to highlight duplicates. In this case, you won't need a helper column.
Hi
How to use the function INDEX and MATCH together.Is it better to use than Vlookup?
Hi David,
You can find the detailed answers to your questions in my recent article: INDEX & MATCH in Excel - a better alternative to VLOOKUP
Hope you'll find it helpful.
Sir,
I have entered in first column category such OPEN,OBC,SC,ST etc then OPEN for 450, OBC for 250, SC for 100 without type the number in infornt of other col. automatically. How it is possible
Hi Kiran,
You can try using a VLOOKUP formula, as explained in this tutorial:
https://www.ablebits.com/office-addins-blog/excel-vlookup-tutorial/