Conditional formatting with VBA for multiple conditions - excel

I have a spreadsheet with a number of sheets used by users. They are asked to input information in some of the sheets and the first Sheet is a summary of results. There are four conditions, if selected, lead to a pens down scenario where no further work needs to take place. Let's say if, Cells A1, B1, and C1 = "No", or if Col 1 in Sheet 2 contains "No", no further work needs to be done in Cells D12:K39, or some such range.
I thought running with conditional formatting may work, but the results are not great. Something like: =$A$1="No", and so on for the other conditions, then I colour out the selection range
I'm very new to VBA, but see this as way to get my results. I have no idea how to structure the above condition.

Don't give up on conditional formatting just yet.
Select Cells D12:K39
Go to Conditional Formatting > Use a formula to determine which cells to format
Enter the formula =OR(COUNTIF($A$1:$C$1,"No")=3,COUNTIF(Sheet2!$A:$A,"No")>0)
Change the formatting as needed

Related

Conditional Formatting Rule Not Working on One Cell

I have a perplexing problem with one of my Excel spreadsheets. I have a "task list" spreadsheet, with conditional formatting to highlight items that are near their due date and overdue. One cell in my entire worksheet is not allowing the conditional formatting, and I am not sure why. It does not matter what is in the cell.
I have tried:
deleting the table row
deleting the entire row
re-typing the cell
re-sorting the cells
deleting and re-creating the rule
verifying that the rule is applied to that cell
Any ideas as to what is causing this?
The affected cell is D5. You can download the spreadsheet here: Google Drive download link
Since that's cell D5, instead of ROW()>5 you should use ROW()>=5.
Also "before today" would be <TODAY() . The +1 makes it "before tomorrow".
It's kind of unusual to have a row number in there at all. I assume you did that so you could apply the format to the whole column but if the extra cells are not dates (like, are just titles) then they shouldn't be affected by the conditional formatting.
If it was me, I would clear all the formatting from that column and in D5 add the simple conditional formatting criteria =D5<TODAY(), then copy that cell, click heading D to select the entire column, Ctrl+Alt+V and Paste Formats.
Better yet, only apply the Conditional Formatting to the cells that need it, not the whole column. Conditional Formatting increases the file size and slow down calculation more that one would think. (I was argued that but was proven wrong!)

Conditional Formatting for a row when there is a text disagreement between two cells

I'm working on a conditional formatting issue. I would like the whole row to highlight if the text in the same row in columns B and C disagree. So far, I've been able to write conditional formatting rules that leave the cell un-touched if there is no data and if there is a data entry that disagrees with the text in Column B, but I can't seem to get the formula to apply to the full row.
Here is what I currently have:screenshot of the document with conditional formatting rules visible
I'm working on Excel 2010. Maybe there is a way to use a logic formula?
I look forward to hearing suggestions!
You can do this with a formula. Highlight the range you would like to format, create a new conditional format, select "Use a formula..." and enter the formula as it would apply to the first cell or in this case row.
In my case, I chose the first 6 rows: $1:$6 as my range. So in this case, I would enter the formula as if I were only entering it for my first cell. The formula =$B1<>$C1 will check for inequality between B1 and C1 in the first row, B2 and C2 in the second row, and so on.

Excel: How to highlight cells if the neighboring cell value differs by 2 or more?

I have several hundred rows of data in sets of two rows. Each row has ratings from 1-5. I need to highlight the cells when they differ by more than 1.
For example if one cell has a "4" and the cell below it is "3" or "5" that is ok. If one cell has a "4" but the cell below it has a "1,"2," or "5," both of those cells need to be highlighted.
I have looked into using conditional formating but this does not help because I can only enter rules asking to highlight < or >, not specific differences of 2 or more.
Background: The data is two sets of subjective ratings of videos of an autistic patient using psychological measures. If one rater differs from the other rater in scoring by more than "1," the data needs to be highlighted so the scoring for that measure can be discussed.
The picture is how the data should look like (not actual data file): http://imgur.com/a/Uym3G
Thank you!!
Assuming you only have two raters and no gaps in Column A after the first video and before the last, please select the range to be formatted starting in C4 and try this CF formula rule:
=OR(AND(ISODD(ROW()),ABS(C4-C3)>1),AND(ISEVEN(ROW()),ABS(C4-C5)>1))
For simplicity, and because I like to always have the ability to quickly change my conditional formatting, I like to use helper columns.
In this case, you can bring a helper column that you will hide afterwards.
Assuming your data starts in A2, and row 1 is your header rows. Assuming we are putting a helper column in B:
In B2 and B3: =ABS(A2-A3)
Drag all the way down
Put cursor in A1, conditional formatting based on a formula.
Formula =$B1>=2
Applies to $A:$A
Hide your helper column
Not sure what you base your statement about conditional formatting on, because what you describe is entirely possible with conditional formatting.
In conditional formatting you don't have to slavishly click the out of the box cell highlighting rules. You can easily roll your own by using a rule with a formula. Consider the following screenshot:
Select cells A2 to A10, create a new rule that uses a formula and enter this formula:
=OR(ABS(A1-A2)>1,ABS(A2-A3)>1)
Select a format and apply the rule to more rows/columns as desired.

IF/AND between two dates Conditional Formatting

I am trying to implement the following logic but my formulas are not encompassing all possibilities.
Am I able to accomplish the following using the approach outlined below?
C5 has a start date(yy/mm/dd), 2013-10-01.
D5 has an end date(yy/mm/dd),2013-10-23.
F3->CX2 has 7 cells merged with the monday's date in the cell.
Example: F3: 30-Sep-13, M3: 07-Oct-13, T3: 14-Oct-13.
F4->CX4 and below are the unmerged seven cells, therefore you have seven cells below each week cell.
My goal is to use Conditional Formatting when cell has value TRUE to fill the background colour of each individual cell between the start and the end date. However I am having trouble determining the correct formula. I have tried the following in F4 and across and below but none have proven to work for all scenario's:
F4=AND(C5=F3, D5>=F3) F5=AND(C5=(F3+1), D5>=(F3+1))...
only fills the cell for the start date not all the cells between the start and end date.
In short, I need to identify the start cell and fill it, continue filling all cells until the end date.
Should this be a macro with a while loop?
***I Believe I have solved my question with the following formula:
=IF(AND((F3)>=$C$5,(F3)<=$D$5),TRUE,FALSE), =IF(AND((F3+1)>=$C$5,(F3+1)<=$D$5),TRUE,FALSE), =IF(AND((F3+2)>=$C$5,(F3+2)<=$D$5),TRUE,FALSE)...Then after 7 cells it becomes: =IF(AND((M3+1)>=$C$5,(M3+1)<=$D$5),TRUE,FALSE), =IF(AND((M3+1)>=$C$5,(M3+1)<=$D$5),TRUE,FALSE)
Should this be a macro with a while loop?
It seems it does not have to be, though that depends upon my interpretation of your question, which seems odd if only because the conditions are not in the rows for which they trigger the formatting.
Select the applicable range starting in F4 and HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true::
=AND($F$3+COLUMN()-6>=$C5,$F$3+COLUMN()-6<=$D5)
Format..., select choice of formatting, OK, OK.
Here's a stepwise view on the problem as I see it:
Set up your data and include the actual date of your "weekly view" as part of the sheet:
Add conditional formatting to a single cell (say, Monday of Week 1) that applies to "a formula to determine which cells to format":
Copy-and-Paste-formats to the remainder of the cells:
The result should resemble:
Change the actual cell formatting to "" to remove the date from view:
The removes the capability to insert any content in the cells (but that wasn't part of the question). If you want to insert content and maintain colouring, you can base the conditional formatting on a similar-sized/shaped layout elsewhere in the sheet and format it accordingly. For example, the following layout provides this yet allows you to enter content in the conditionally formatted area:
Use the formula conditions. I put a start date in A1, and an end date in A2. Modify as needed per your requirements.
Then I will apply conditional formatting to values in range E1:E6. Again, modify as per your requirements.
Then simply use Highlight cells Rules > Between
Then, select your start/end values and press OK. Voila!

Excel conditional formatting of adjacent cells from a drop down list

I've been searching around here but I can't find anything quite like what I'm after.
In excel I have one column with a drop down list of a dozen different initials, with conditional formatting on those cells. I would also like to format another column based on those initials, but don't want to set up a dozen rules on each cell, one by one. If I set up the top cell with the correct rules I cannot fill the formatting in because the formula is not updated on a row by row basis, but en bloc for the range.
I have no real experience with VBA or macro's, is there a way to do this more elegantly than brute force?
Thank you very much in advance. This forum has always been a great help, hopefully you can help this, too!
I hope I'm not misunderstanding your question. You can copy the formatting to the other columns if you have set up the format as a formula. For example, if A is your column with initials, and you have a data cell in B2, then you can set a formula in B2 as A2="ER", for example, with the formatting you want, and do the same for the rest of your matches on A2. Then, you can copy the format down column B (unfiltered) using Paste Special Format. You can copy the conditional formats across as long as you make sure that your format in the conditional formatting rule is anchored on column A (i.e., $A2="ER").

Resources