I require to highlight an entire row in Excel if a cell string contains the word "site" in column G. I am using conditional formatting with a formula which uses the following formula which doesn't work.
=INDIRECT("g"&ROW())=MID("g"&ROW(),FIND("site","g"&ROW(),1),4)
On a side note: the following works perfectly but only for exact matches where the content of the cell ONLY contains "site" as string:
=INDIRECT("g"&ROW())="site"
You don't need to use INDIRECT of MID, if you can use some lock mechanisms:
=FIND("site",$G1)>0
Here, you will see the active cell is A1, so the corresponding row Excel will compare it to will be G1, when conditional formatting looks at cell A2, it will compare it to G2.
When the conditional formatting looks at cell B2, it will compare it to G2 again because G was locked (via the $ symbol).
That said, your formula was not working because FIND("site","g"&ROW(),1) fails. The second argument gives the text g# (where # represents the row number) and the search fails).
Related
Is there a way to create a formula in one cell that will change the value in another cell based on some criteria, without scripting? Example: cell a1 contains a numerical value. cell b1 contains a value from a drop-down list, say, "YES,NO". If cell b1 is set to "YES" I want to remove (set to zero) the value in cell a1. What I'd like to do is have a formula in cell c1 that interrogates b1 and sets the value in a1 accordingly. Is the only way achieve this writing code and using setValue?
you cant remove it without a script. you can visually hide it in various ways. if the A1 is subject of further sum (as in your case per your comment) the sum formula can be always altered to reflect desired output. example:
if your formula is
=SUM(A1, C5, D22)
you can do
=SUM(IF(B1="YES", 0, A1), C5, D22)
Use the following on the cell you need the calculation (or zero) on:
=IF (B1="YES",0,SUM(A:A))
Using the given formula, you would do the SUM calculation for the whole Column A if the value on B1 is "YES", if not, then a 0 would be placed on the cell you put the formula on.
i have two columns (Start Date, End Date) and i want a code that changes the color of both their cells to red if the start date and end date contained any date located in another sheet
I tried using conditional formatting using this rule: =AND(C2<=Holidays!$A$2:$A$15,D2>=Holidays!$A$2:$A$15)
Tested out the below formula for myself and think it should work! Effectively rather than a simple AND statement, since we're comparing against an array of values rather than single cells, we need to use some handy array formulas. This post gives a good breakdown of what's going on under the hood: https://exceljet.net/formula/index-and-match-with-multiple-criteria
Apply this formula in conditional formatting, assuming the range you're formatting starts at C2.
=SUM((Holidays!$A$2:$A$15>$C2)*(Holidays!$A$2:$A$15<$D2)) > 0
Also, wanted to call out the absolute references specified for columns. I've specified **$**C2 and **$**D2 in my formula, which means that no matter which cell in your conditional formatted range it'll evaluate off the values in column C and D. In your current formula, cell C2, would evaluate on C2 and D2, but cell D2 would then evaluate off D2 and E2. This'd be why when you tried the manual formatting only the start date cells (column C) were formatting correctly.
Hope this helps!
Update::
If you had a table format like in the attached screenshot, you would apply the conditional formatting formula:
=SUM((Holidays!$A$2:$A$15>$C2)*(Holidays!$A$2:$A$15< $D2)) > 0
To cell range $C$2 : $D$3
If you're changing the cell range (say you wanted to apply to $C$10 : $D$14), you'd just change the $C2 and $D2 in the formula --> $C10 and $D10.
I am trying to figure an Excel formula and Google is not helping.
I almost have what I am trying to do, but need a 'dummy' column where I do the math in the column cells.
What this means:
1) What I have working:
Cell A1, with math formula (I wish to delete this 'dummy' cell and incorporate this into the formula in Cell B1, see further explanation below)
=SUM((6.75*1)+(5.73*2)+3)
Cell B1, with value from Cell A1 but limited to an integer less than or equal to 80
=IF(SUM(A1)>80, 80, SUM(A1))
Cell C1, with a value looking at Cell B1 and entering in this cell either 0 or any integer greater than 80
=IF(SUM(A1)>80,SUM(A1)-80,"0")
Note: This works perfectly, I change any values in the Cell A1 formula and it correctly reflects in Cells B1 & C1.
2) The missing piece:
I would like to combine the two formulas above in cells A1 & B1 into one cell, and still have the same results described above for each of the cells.
To articulate this another way is:
have a cell with a math formula,
calculate the results of that formula, and then,
enter back in the same cell that formulas results,
with the condition of 'less than or equal to 80'
while a formula in an adjacent cell is dependent on the calculated, but un-printed, value of the first cell.
As an example:
Using only Cells A1 and B1 in a spreadsheet, and combining the above working formulas (which do not work for me in Excel), it would look like this:
Cell A1:
=IF(SUM((6.75*10)+(5.73*7)+8.5)>80, 80, SUM(B21))
Note: Cell A1 formula from above, =SUM((6.75*1)+(5.73*2)+3), combined with Cell B1 formula from above, =IF(SUM(A1)>80, 80, SUM(A1)) (with the Cell A1 formula replacing both 'A1' values in the Cell B1 formula).
Cell B1:
=IF(SUM(A1)>80,SUM(A1)-80,"0")
Note: Identical to the Cell C1 formula above.
Is it possible to do this, calculate the results of a cell's formula, while a formula in an adjacent cell is dependent on the calculated, but un-printed, value of that first cell?
I realize writing this out, it's more complicated than I originally anticipated, which explains why Google wasn't getting me anywhere.
Thanks for any hints.
Phil
Strictly speaking, this is not possible. A cell has only 1 value and that is the result of all calculations. The IF statement is not hiding the value of the cell. It is changing the value.
A formula to another cell can only use the final value of the cell. It can't extract part of the formula in the other cell. There's no way for Excel to know which part to extract, even if there's only a single calculation in an IF statement.
That said, there is a different workaround possible in your case... and that is to change how your value is displayed through custom formatting. Formulas change the value of cells, whereas formatting changes how those values are displayed.
Place your formula in cell A1: =6.75*10+5.73*7+3
Right click on cell A1 and select Format Cells...
Make sure you're on the Number Tab
In the Category column, select Custom
Enter this formula in the Type box: [>80]"80";[<=80]General
Enter this formula in B1:=IF(A1>80,A1-80,0)
Check that the number format of B1 is still "General" or "Number"
The result is A1 has calculated and stored the actual value, but displays the text string "80" if it's value is above 80. You can then use the actual value from A1 in other formulas.
NOTE: This type of custom formatting is extremely poor practice as it can become very confusing and very error prone. The value of the cell is different to what it is showing and if other users are unaware, creating new formulas referring to the affected cell can unwittingly produce incorrect and/or unexpected results.
In particular, Excel tries to be helpful and can automatically copy the formatting from one cell to another if it is next to the original cell or if it refers to only the original cell in a basic formula. Copying and pasting also copies the formatting by default. Unintentionally copying the formatting to other cells will also alter how they appear.
Also note that you don't need to put SUM() around a formula that already had the addition operators included; and Excel uses order of operations so you don't need the brackets to do multiplication before addition.
Lastly, you could also just use =MAX(A1-80,0) in B1.
Given the example:
A1: Smith, John Michael
A2: John Michael Smith
What is the formula if I want to format cells (let's say color the cells green) when it finds the string "Smith" in both A1 and A2?
A1 -> list from excel file
A2 -> list from database
I'm comparing a list of names extracted from a user database and the list of names on an Excel file to see if which ones are missing in the database.
Assume you place the word you are looking for in A4, you could use the following formula:
=AND(ISNUMBER(SEARCH(A4,A1)),ISNUMBER(SEARCH(A4,A2)),NOT(TRIM(CLEAN(A4))=""))
Search will look for the text entered in cell A4 and see if it can be found in A1. If it is found it will return a number and if is not found it will return an error.
Isnumber checks to see if the search returned a number. if search found the word entered in A4 in A1, it will return the number of the starting position and is number will then return a value of TRUE.
The process is then repeated for the text in A2.
In order to say that the text is found in both locations you need all arguments in the AND formula to be TRUE. if any one of them is false AND will return a value of FALSE.
The final step will be to apply conditional formatting to the cells. Use formula as your method for your conditional formula control and use the above formula in the space provided. Set your special format for when your formula returns a true value.
Depending on how you apply your conditional formatting, you may want to use $A$4 instead of A4. Same goes for A1 and A2.
The last logical check that was added was to make sure that if no information was entered in A4, or a space was entered in A4 that the check would colour the cells. In other words it will only colour the cells if there is actually something to look for in A4.
I have a range of reference locations on Sheet 2, column A. I have a list of locations on Sheet 1, column F. I can get the cells in Column F to highlight if they match one of the reference locations with this formula in conditional formatting: =COUNTIF(Sheet2!A:A,F4:F2500).
What I want to do is, instead of highlighting the cell that shows the location in column F, I want to highlight the adjacent cell in column G.
I've found ways to do what I already have working and I have found ways to highlight a cell based on another cell's value, but I can't figure out how to connect the two.
You can actually use the exact same formula, just apply it to the cell next to it.
I changed the formula a little, but if you create a new conditional format in G1 and use this formula: =COUNTIF(Sheet2!A:A,F1) it will compare the value in F1 to the options in Sheet2 column A and if it finds it, it will apply the format to G1. Then apply the formula to the other cells in Sheet1 column G as needed.