I'm trying to conditionally format each of the rooms so that they will be Red normally but green if the room will be available for a particular day. The date of interest will be changed on the top left of the "Office Rooms" Tab. The values in the "Form Responses" Tab populate from a google form.
Values to consider:
Room numbers on the "Form Responses" Tab
Date range on the "Form Responses" tab
Date at the top of the "Office Rooms" Tab
I've tried IF statements and I know about using INDIRECT. But I think this may just be too complicated for the normal "Conditional Formatting" route. I may need to use Apps Script but I'm not too familiar with that yet.
I've posted a link to a copy of what I'm working on below. Thank you in advance for any help you can throw my way!
Link to Google Sheet
This can be done with conditional formatting alone, using the following custom formula.
=isna(filter(indirect("'Form Responses'!B:D"), indirect("'Form Responses'!B:B") = B4, indirect("'Form Responses'!C:C") <= $C$2, indirect("'Form Responses'!D:D") >= $C$2))
As written, this can be applied to B4 and any range that has B4 as upper left corner. For other ranges, change B4 to its upper left corner.
Explanation: the filter command filters the indicated range according to criteria: B matches current cell, C and D are around the date stated in C2 of current sheet. If there is no match, then the result is #N/A and isna evaluates to True, triggering formatting (which would be red).
The formula would be a lot shorter if the data was on the same sheet. As is, one has to refer to 'Form Responses'!B:B and such, which within a conditional formatting rule requires indirect.
Related
I would like to highlight a cell which is the closest the a specific value but still lower (below) or equal according to a formula.
For instance, if I have 14 in B4, I would like the cell 13 (or 14) highlighted but not 15 in the range.
The value I need to look for would be in B4 and the range that I must apply the highlight formula to would be L1:L371.
So far, the best result I was able to achieve was with (from what I was able to find using Google or Stackoverflow already existing content):
=SMALL($L1:$L317,COUNTIF($L1:$L371,"<="&$B$4))
Although, not only it selects the value I am looking for, it also selects all the values below.
May someone provide me some help so I can achieve the expected result please?
Thank you for your time and help, it is greatly appreciated.
Based on your description, it seems like you need to find the maximum value of a range (L1:L137) that is less than or equal to an input variable (B4) and highlight that value in the search range. Depending on what version of Excel you have, here's what you need to do:
For Excel 2019 or Excel 365
You can use the MAXIFS function. You would actually put that function in a conditional formatting rule, but more on that in just a second. As a test, put the following code in cell B5:
=MAXIFS($L$1:$L$137,$L$1:$L$137,"<="&$B$4)
The first argument is your "MAX_RANGE", or the range that contains the values you want to find the max of. It is also our "CRITERIA_RANGE", the second argument. The third argument is the criteria itself, which is that the search range must be less than or equal to the value in cell B4. Essentially, we are going through the list and creating a subset of numbers that are less than or equal to our search value, and discarding the rest. I assume you are aware of relative vs. absolute referencing, since you used the "$" anchor in your referenced code. If not, here's a description of the difference.
Now, the result of that formula should be the highest number in the list less than or equal to the search value, but that doesn't highlight it for us in our list. To do this we need conditional formatting. To do this, highlight your data range (L1:L137) and go to the conditional formatting drop down on the home tab of the menu ribbon. Choose "New Rule". On the dialog that pops up, choose, "Use a formula to determine which cells to format". In the formula input box, enter:
=L1=MAXIFS($L$1:$L$137,$L$1:$L$137,"<="&$B$4)
This will compare whether the value in the cell being evaluated (L1, for instance) is equal to the result of that formula we talked about above. Since L1 is only relatively referenced, this formula will work for every cell in the data range.
Now, before you hit "OK" on the dialog, select the Format button. This will allow you to adjust your highlighting and formatting as you desire. Click "OK" on the formatting dialog, then "OK" on the Conditional Formatting Rule dialog. This should now highlight any data cell that is equal specifically to the result of our formula, and not everything that's less than our value.
For Earlier Versions of Excel
The concept is the same in earlier versions of Excel, but unfortunately, the MAXIFS function is not present in these versions. Instead, we must use an array formula. Array formulas are a whole other can of worms, but ExcelJet is an excellent resource. In fact, they talk about this very issue, here.
Unfortunately, we can't put the array formula in the conditional formatting formula like we did above, so we'll need to put this formula on a cell in the worksheet, then the conditional formula should reference that new cell. So in cell B5, if you put:
=MAX(IF(L1:L137=B4,L1:L137)
And then, instead of pressing Enter, you must press Ctl + Shift + Enter
This keyboard combination will tell Excel that you are trying to enter an array formula. If you don't press these keys, then the formula will error. Once you have entered the array formula, if you put your cursor in cell B5, you will see the formula bar at the top has added curly braces ({ , }) around the formula to look like
{=MAX(IF(L1:L137=B4,L1:L137)}
This leads to the same result as above, but is just achieved slightly differently. Now, following the same process described above for conditional formatting, you will simply set the formula to:
=L1=$B$5
And that should be it! Hope this helps!
I've got a workbook, that i use for fleet allocations, but i'm not sure how to do error checking in excel, and was wondering if anyone could point me in the right direction. When i allocate the vehicles to a duty, it uses vlookup to bring the driver name into the sheet. but what im unsure of how to do is, i have 54 duties, and it would be easy to miss one, so is there a way i can make it show me which duties are left to allocate ? please see screenshot...
Excel Worksheet Screenshot
For a layout as shown:
Select ColumnA, clear any existing CF from it 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(A1<>"",COUNTIF(C:E,A1)=0)
Format..., select formatting of choice (I chose the same fill as for the headers) OK, OK.
Well, had a look at your sheet... But I put this together as it is simple and you may be able to include it where you can...
Tha match() function looks for the duty in cell A2 and if it finds it in the list in column I then it returns its position number. If not found the iferror() returns "Not Allocated"...
The formula in cell B2 is:
IFERROR(MATCH(A2,J$2:J$10,0),"Not Allocated")
I have been trying to change the color of certain cells on my WS that fall outside of an acceptable range. The statement I've been trying to use is,
IF(OR('cell'>1.3,'cell'<2.5),'turn red','do nothing')
In english, "If a cell is less than 1.3 or greater than 2.5 turn red, else do nothing." I cannot find a resource that guides me to how I can get the cells to change colors. I also have been unsuccessful in creating a statement in the Conditional Formatting tab that satisfies my goal. I feel this should be simple, but for some reason cannot figure it out. Does anyone know if this is possible, and if so how to do it?
EDIT: Also, I have different ranges based on another cell on the spreadsheet. I need this also taken into consideration
Select the columns that you want to format
Click Conditional format --> new rule
Select "Use a formula to determine which cells to format"
In the formula bar enter the formula =AND(A1>1.3,A1<2.5)
Choose the fill color as red and press OK
am confused with your formula and your english version. If its the other way, then use the formula =OR(A1<1.3,A1>2.5)
On a brand new Excel file, I want to use commandButton_click to see if any of the numbers are ouside my tolerance (example +/- 0.0005)
IF any of the numbers are outside the tolerance, it should highlight the "wrong" cells (see picture).
Update: If someone know how I can do that in Conditional Formatting please show me. Thank you very much!
With conditional formatting you would do it as follows:
Select the cells in the range A6:O7
Click Home > Conditional Formatting > New Rule.
In the New Formatting Rule dialog box, click Use a formula to determine which cells to format.
Under Format values where this formula is true, type the formula: =ABS(A6-A1)>$D$4 (make sure the reference $D$4 corresponds to where you have the tolerance input).
Click Format, and then choose the formatting options you want to apply to values which are outside the tolerance.
Click OK on all open dialogs.
You don't need the command button with this solution, as Excel will apply the formatting immediately. Just take care not to paste formatting, because then you will destroy the above configured conditional formatting. So only paste values.
This is a slight variation of #trincot 's idea. You can create a named range which stands for tolerance and then use that for greater readability. Note that you have to do this twice, once for the upper cells and once for the lower cells:
If you haven't used named ranges before, select the two cells (A4:B4 in the screenshot) which contain the tolerance and click Create Names from Selection on the Formulas tab.
Lets say I have a name in cell A1. I'd like to make that cell green if there is "o" or "x" in any of the cells spanning B1:Z1.
Also, could you do this thing on a larger scale if you have 20 names under column A from A1:A20; so you don't need to format each cell individually?
Here is an example of my naughty and nice list:
A B C D
Name Mon Tue Wed
Mark x x
Donna o x o
Amy x
I tried to do it with conditional formatting on A2
=OR($B$2:$H$2="x";$B$2:$H$2="o")
but in this instance it only works on the first two examples, since the B column has a value in it.
Is it possible to do that on a list of 40 people on a mass scale. to not have to do formatting for each row seperately?
I'm using Excel 2013 if that helps in any way.
Ahh, now that I understand the question, the conditional format option can be applied.
Select cells A2:A20
Go to Conditional Formatting on the Home tab
Click on New Rule... and you will see something like this
Click the "Use a formula" option and enter this in the "Format values where..."
=OR(COUNTIF(A2:H2,"x")>0,COUNTIF(A2:H2,"o")>0)
and then click the Format... button to apply a green fill to the cells.
I'm using COUNTIFs because comparing or testing a range for a specific value needs an array formula which I've never really considered for a conditional format. It may work but I prefer the KISS principle.
I would do what you have (the OR expression,
=OR(NOT(ISBLANK(Table2[#[B]:[D]]))) (as an array, shift-+ctrl+enter)
) and put it in it's own column(E). Then just look at that with a formula in the conditional formatting that looks like:
=E2
for me this formula: =OR(B2:X2="o",B2:X2="x") produces the desired result, and I don't experience the strage problem "when B is empty" as you describe.
Not sure about the difference between ; and , separators - it has something to do with regional settings (some info here)