Excel Conditional Formatting, Referencing 2 cells to the Right with conditions - excel

I have a list of students who are between the ages of 3 and 5. lets say column A has the code, Column D has the childs age & Column F has their age group (3-5) If their age exceeds the age group then the Cell in column A will highlight Red. I am just not sure how to write this code correctly, all of the combinations i have tried come up with an error or just don't do anything.
IF(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,7)="3-5" & (OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,4)>5 {THEN FILL CELL RED} {ELSE NO FILL}

In the first part of the statement you are checking whether the cell 7 columns across = "3-5". You don't need to use offset for this, you can just reference the cell 7 across directly.
So if you're applying the conditional formatting to A1 that part of the formula would just be =IF(H1="3-5",{then},{else}).
If you just want TRUE or FALSE as the answer you don't need the IF statement, so this shortens to: =H1="3-5",
If you're applying the conditional formatting to a range instead of just an individual cell, say A1:B10, then you write the formula for the cell in the top left of the that range. So for A1:B10 you would still you the same formulae as above.
For the second part of the statement, using the same logic as above, you get: =E1>5
To check both statements together you need to wrap them in the =AND() function, giving you this as the final formula for your conditional formatting:
=AND(H1="3-5",E1>5)

By using the AND function I can achieve the desired result without cell references moving if a cell is relocated.
=AND(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,7)="3-5yo",OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,4)>5)

Related

check multiple cells value in a sorted list have same value as another manual cell

How to write a formula in excel that based on critria it can check if list of multiple result cells have same value.
I attached example:
Look for all cell with the number 100
Verify that the list of these cells contain same date value of one cell.
I try to use formula such as: COUNTIF + INDEX and MATCH but didn't work as expacted.
I'm guessing you can use =ROWS(FILTER(....)) but what I would do is create a hidden column that evaluates it per row, maybe with something like
=IF(A2="","",XLOOKUP(A2,A$2:A,B$2:B)=B2)
and copy that formula down the column.
This way, you can not only see if there are any bad values (by COUNTIFS for false values where the A-column's value matches the "find these cells" value) but apply conditional formatting as well to highlight the bad values.

Comparing two columns and highlighting if the specified value is not available

I have two columns A and B, If A Column have the specific value "High" then the corresponding cell in B Column should contain the Date (dd/mm/yyyy)value otherwise if date value is not available the cell should be highlighted as Red. I am new to this macro and I am not able to find the logic for this.
Sorry this isn't a comment, but I don't have sufficient rep.
I'm a little unclear how dates are populated in column B. Is this something we can take as given or are you assigning dates somehow? It might help if you could share a bit more about the structure of the sheet, maybe some "dummy data"?
That said, this sounds like a straightforward case of loops + conditional statements. I doubt this will work for you out of the box, but you could try nested For loops over columns A and B à la:
For Each cell in Range("A:A")
If cell.Value = "High" Then
If IsEmpty(Range("B"&cell.Row)) Then 'IsEmpty tests whether the cell is empty, you may need to change this if the cell has some other value in it
Range("B"&cell.Row).Interior.Color = 255 '255 corresponds to the color red
End If
End If
Next cell
I agree with Pᴇʜ though, you don't actually need VBA for this at all. You can apply conditional formatting using a formula for the rule and then use a formula like this for the cells in column B:
=IF(A2="High",IF(ISBLANK(B2),TRUE,FALSE),FALSE)
Then just make sure you apply the formula to all the rows you care about.

Conditional Formatting using multiple vlookups

I have an excel spreadsheet and I am trying to do conditional formatting based on multiple conditions. I have to highlight the rows where (Column A value matches column C) AND (Column B matches column D). I tried 3 ways but none of them are giving me expected results-
Method 1 - I tried conditional formatting with these 2 Rules-
(VLOOKUP($A2,C2:C93,1,FALSE))>0
(VLOOKUP($B2,D2:D93,1,FALSE))>0
and applied it to $A$2:$D$5745
but this is not working as expected.
Method 2- I tried using if but this is also not providing me desired results
=if(VLOOKUP(A2,$C2:$C93,1,FALSE)>0 & VLOOKUP(B2,$D2:$D93,1,FALSE),True,False)>0
applied it to $A$2:$D$5745
Method 3- =AND((VLOOKUP($A2,C2:C93,1,FALSE))>0,(VLOOKUP($B2,D2:D93,1,FALSE))>0)
applied it to $A$2:$D$5745
To rephrase this problem- I would like to highlight all rows where CustEID in Col A and Account EID in cloumn B match CustEID in col C and Account EID in col D.
Can someone please guide me?
Here's what I was able to get working.
The VLOOKUP evaluates to return either the "found" value or #N/A. By modifying your formula with a logical check >0, this converts the result to a boolean value (TRUE) but only in the case where VLOOKUP is returning a valid value. In many of your cases, your formula still evaluates to #N/A.
So this: =VLOOKUP(A2,$C$2:$C$93,1,FALSE)>0 will return either TRUE or #N/A.
I've modified the formula to =IFNA(VLOOKUP(A2,$C$2:$C$93,1,FALSE)>0,FALSE), which forces the entire formula to return a true boolean value TRUE or FALSE.
The cell range references in your formulas need to be locked into specific ranges that will not be evaluated as "relative" in the context of the conditional format formula. So your formula VLOOKUP($A2,C2:C93,1,FALSE) using the range C2:C93 will also "slide" (my own terminology for this formula going "relative") as it progresses down the rows. So each of your formulas needs to lock this down with VLOOKUP($A2,$C$2:$C$93,1,FALSE).
Notice that the only portion of the formula that stays relative is the row number -- the 2 in this case. So you'll start your conditional format setup on row 2.
Combining these formulas for the full test you want to apply gets you
=AND(IFNA(VLOOKUP($A2,$C$2:$C$93,1,FALSE)>0,FALSE),IFNA(VLOOKUP($B2,$D$2:$D$93,1,FALSE)>0,FALSE))
Applying this to your conditional format as a full row requires one last adjustment. Instead of applying your rule to the range $A$2:$D$5745, you have to remove the column references. So the application range becomes $2:$5745.
This is what I get when it's all put together:

Replicating conditional formatting in Excel

I'm having trouble using Conditional Formatting in Excel. No problem with setup for one row, but no luck replicating it to the rest of the worksheet.
A B C D
1 MATCH_RESULT CODE DESCRIPTION CHECKUP
2 #N/A A1 Chair #N/A
3 #N/A B1 Window #N/A
4 2 C1 Table #N/A
The goal is to identify if column A is filled with value #N/A (default error message for MATCH function). If it is, cells in columns - A, B, C - ONLY ON THE SAME ROW should be formatted (with color red). I.e. as per example, A2:C3 should be formatted.
This is working for me, however just for the first row and I fail to correctly replicate this downwards.
I'm selecting A2:C2 -> Conditional Formatting -> New Rule -> Use a formula to determine which cells to format.
I will end up with the formatting setup such as:
Formula: =$A$2=$D$2
Applies to: =$A$2:$C$2
A2 through C2 will be formatted, as expected (due to A2=D2). However I can't replicate the same thing on next rows. Format painter function will expand the current functionality so that still A2=D2 match is looked at for formatting other rows, instead of A3=D3 and so on.
Pretty sure the key is in $, but nothing has worked yet. Also pretty sure Excel allows just one cell in column D to be populated with value #N/A for comparison.
You have three issues, first your range is (part of) a single row =$A$2:$C$2. Try selecting ColumnsA:C before adding the rule, or change Applies to to:
=$A:$C
Second, you have anchored the row references in your formula. The 'style' should be:
=$A1=$D1
However your third issue is that comparing errors (#N/A resulting from a function) returns ... #N/A (so I don't know how you managed to get even a single row to work, since CF needs a TRUE result to trigger).
Maybe try:
=AND(ISNA($A1),ISNA($D1))
Replace the formula part with
=iserror($A2)
you may need to remove the $ manually.

Applying an if statement formula for the entire row in excel

I have an if statement working properly in only one cell. =IF(B28="Others",+C28, 0). However, I also want to include the cells B28 to B30 and will add C28 to C30 respectively in the formula. How will I be able to do so? I have tried this formula: =IF(B28:B30="Others",+C28:C30, 0) but it won't work.
What I want to happen is this:
I will input values in the cells C28:C30, and if they're under a certain category (ex. B28 says 'Others'), that value will be added to that category above (ex. C18 for 'Others').
If it works, C18 should have a value of 1,450 since 1,150 and 300 are both under 'Others'.
The function you're looking for is SUMIF(). You can read about it here.
The complete formula you need is: =SUMIF(B28:B30,"Others",C28:C30)
you might want to use a sumif statement where you're summing on the values in C based on the category in B
http://www.exceltrick.com/formulas_macros/excel-sumif-and-sumifs/

Resources