Comparing cell values in Excel - database

What I am trying to achieve is to see if the value of Cell C4 exists in Column F.
If it exists in Column F, I eventually want Cell A4 to copy the format of the cell in Column F that matches the value of Cell C4.
Still following me?
For reference, my file looks like this:
The values of the cells in Column A are based on Sheet2.
So with a simple formula I managed to compare the values and only change Column A when there is an actual match as seen below.
=IF(C4=F:F, IF(C4<>"","x",Sheet2!A4), Sheet2!A4)
The only problem here is that it only results in a TRUE statement, if Cell C4 matches Cell F4. If it matches, let's say Cell F5, the statement will be FALSE and I need it to be TRUE (since value of C4 is indeed found in Column F.
I tried a variation using $F:$F instead of F:F, but this made no difference. Also setting a range (F2:F5) did not work.
This is where I am stuck.
As soon as I have this figured out, I can continue finding a way of copying the format of the matched cell. Feel free to reveal how I manage to do this if you already know. Will save me some headaches.

Try the following:
=IF(IFERROR(MATCH(C4,F:F,0),0)>0,IF(C4<>"","x",Sheet2!A4), Sheet2!A4)
Edited formula error (; --> ,)
EDIT:
Ok, so forgetting about you formula and trying to do what I think you want, which is:
Be able to copy in the list of resolvers at work into your color code scheme, and then apply that format to all tickets where this person is responsible. There has to be a way of telling, based on color, whether a ticket is assigned to a person that is not on the job (not in the list), or is not assigned to anyone. I assume you have a very limited amount of people at work, because if not, it will be very difficult to distinguish between the colors.
Being quite few people at work at one time, what you could do is to:
Name your the range with people at work "workers"
Name the new range "colors"
For each row with a color coding, enter the name of the color, or some other way of referencing the color. I entered "Yellow" "Red", "Green", "Blue", and I added a black for "x".
Selected the top cell in the tickets column, selected new conditional formatting rule, entered the following formula
=IFERROR(INDEX(colors;MATCH($C1;workers;0));"x")="Yellow"
Selected that this should have yellow fill, and applied to the entire Tickets column.
Did the same for red, green, black, etc.
Doing this, I managed to get the following behaviour:
1. I can change the names in the name column, and conditional formatting will not change
If a ticket is solved by someone in the list, the background color of TicketX is the same as the name in the name list
If a ticket is not solved by anyone, the formula returns "", which is not in any of the conditional formatting rules, so it remains white
If a ticket is solved by someone not at work, formula evaluates to "x", which is tied to color black in conditional formatting, so the cell turns black (could consider adding white text here to be able to see ticket number).
Now this is not that pretty, because you have to create so many rules, but as I say, if you are to distinguish between the colors, there can't be too many of them anyway.

To answer the first question of seeing if C4 exists in column F, you can put the following formula in cell E4.
=IFERROR(INDEX($F$2:$F$5,MATCH(C4,$F$2:$F$5)),"")
It will put the name if it exists and have a blank field if it doesn't. Just drag this formula throughput column E (or whatever column you want).
In order to match formats and don't want to get into VBA (and assuming you don't have a lot of possibilities), you could add conditional formatting to the new column of E. With the "Classic" Style of conditional formatting, make a new rule that sets your custom format when the cell contains the specific text of "Henk". Then continue on making rules for the other possible options. After you create the conditional formatting in, say, cell E4 for example, change the "Applies to" field to apply to Sheet1!$C$2:$C$5.

Related

How do I search for a cell by its text, then display the value of the cell to its right in Google Sheets?

So, I need a formula that searches for a cell in a specific row (or one of multiple rows) by its text, then displays the value of the cell to the right of it. I don't even know how to begin to do this one...
Here's an example of this:
Here is an example of a list of phrases with associated numbers that'll come up later in the sheet.
Here I want a formula that searches for instances of the word in the cell to its left appearing in Column A, and then display the value of the cell to the searched cell's right. Note that I'm only searching for phrases that come up once...
...and this is what I'd want the result to be.
(I'm on mobile, if that affects anything.)
EDIT: Also I've realized, unlike in the image the formula would actually be searching for a phrase TWO cells to its left instead of one, sorry!
try in H26:
=INDEX(IFNA(VLOOKUP(G26:G, A:B, 2, 0)))

How to maintain true Blank Cells when copying a column

Problem: I have data in Column A as headings of some sort and in column B I have subheadings.Because of this column A has blank cells between the headings.
If I set Cell A1 in a second sheet to be equal to A1 on the first sheet and copy this throughout the blank cells return as '0'. This messes with formulas that rely on true blank cells.
I've attached and image to visually explain the problem.
To replicate the desired output and the problem:
Enter random data into columns A and B leaving blanks in column B.
In column C enter: =SUBSTITUTE(FILTERXML("<t><s>"&TEXTJOIN("</s><s>'",,A1:B50)&"</s></t>","//s"),"'","")'
This Will return a correct result combining the heading and subheadings in a logical order.
.
However if you set say column E and F to equal Columns A and B respectively and enter the following in column G: =SUBSTITUTE(FILTERXML("<t><s>"&TEXTJOIN("</s><s>'",,D1:E50)&"</s></t>","//s"),"'","")
The data will return correctly sorted but now with a bunch of 0s between each heading and subheading because the formula now includes cells that were originally blank as 0.
What I've Tried: Aesthetically you can set '0' Cells to not display 0 in advanced setting but as the name descries its still a 0 and just hidden but not from the formula. I have tried setting the cell to Text only to try and eliminate 0 but this has no affect as numbers are still recognised as text. I have also tried to eliminate 0 with the code =IF(E1="0","",E1) and =IF(E1="0",NA(), E1). This removes the 0 or adds N/A# but ultimately these cells are still recognised as such by the above formula and a 0 is entered or the formula fails.
Does anyone know how to make one column with blank cells equal to another and still maintain True Blank Cells and not 0s? Alternatively if anyone knows how I can modify my formula to ignore 0s that would be great too. I don't have any experience in VBA but I'm willing to learn/copy and paste a code that will remove this problem.
Any help is appreciated, or if you think its not possible let me know.
Please try this formula in your cell E2 and copy down.
=LOOKUP(2,1/($A$1:$A2<>""),$A:$A)
The opposite effect is achieved with this formula.
=IF(A2="","",A2)
The first formula will copy the header to each row even where the source is blank whereas the second produces a blank cell for a blank cell. Another ay is to allow the zeros to be written but suppress their display with a cell format or a universal setting (for the whole sheet) that suppresses display of zero values.
Did you mean you would like to use a condition in TEXTJOIN(), a nested IF():
Formula in D1:
=SUBSTITUTE(FILTERXML("<t><s>'"&TEXTJOIN("</s><s>'",,IF(A2:B13<>0,A2:B13,""))&"</s></t>","//s"),"'","")

SUM with IF conditions for cells containing both strings and numbers

I've got a bigger table with one column that I want to focus on, containing designation and a number. I want to simply sum the numbers that meet the criteria based on a designation.
For the simplification, I made an exercising sheet (on the pic) where I split second column into two - one string and one numeric. Since my file is quite large with many columns that would need this it would be inconvenient.
In the left column it's easy to solve the problem, it could be even easier with simple SUMIF function, but an array SUM(IF... function is, at least I think, only viable option here.
So I solved the first table with array function, but what confuses me is how to modulate the TRUE statement. Simple replacement of C:C
with
VALUE(MID(F:F;4;4))
which would format my cells to get the numbers from string does not work that way - returns zero in E12 field. F12 is just application of string to number for last cell, F10.
THIS formula does not work, even adapting to different versions of the tool.
I could use VB but if possible anyhow I would like to avoid it since parts will be shared on mobile phones.
Any ideas? Thanks a lot!
Left table was split, right original format
The array formula which you used can be replaced by the SumIf formula like below...
=SUMIF(B:B,"B",C:C)
Also without the helper column, you can use the Sumproduct formula to achieve the desired output.
But don't refer the whole column in the formula like in the above SumIf formula.
Try this..
=SUMPRODUCT((B1:B10="B")*MID(F1:F10,FIND(",",F1:F10)+1,255)*1)
Change the ranges as per your requirement but remember to make them equal in size.

How to arrange table data differently by using if, match, and index?

As shown in the attached image, I need to convert A2:D10 to the format of A12:E17. The 4 tables from F1 to AB12 are my experiments using if, match, and index. Same formula gets different results and it seems to be dependent on the row position of the tables. In My previous question, I was trying to pinpoint the problem to the if function.
What am I doing wrong here?
Thanks,
Lu
enter image description here
Again, as I said in your last question: The formula has not been array entered. Array formulas need to be confirmed with Ctrl-Shift-Enter.
Without that, the first array in the IF statement does not get resolved and the Match does not return the correct result.
Make use of the Evaluate Formula tool and step through the formula.
The merged cells don't help with the cell referencing. Unmerge the cells and fill in all the labels in row 1, then use this slightly amended formula and confirm it with Ctrl-Shift-Enter. Then copy across and down.
I hope that I get the English names of the functions right:
In D14 and following cells:
=INDEX($C$1:$C$5;MATCH(1;MMULT(($B$3:$B$10=$A14)*($A$3:$A$10=B$13);1);0))
The MATCH function tells which value (by number counted from the top) matches both conditions. The INDEX function returns this value from C1:C5.

Format text in flow document table cell

I have a program that creates a table, adds it to a flow document along with table cells that are populated with text. Everything works great with one exception. One column of cells in the table displays costs and they have been formated as follows:
cellValue = "$" + string.Format("{0:##,#.00}", int.Parse(cellValue)).PadLeft(22 -
cellValue.Length);
As it turns out, with this formatting numbers like $ 11,111 take up a different width then numbers like $ 10,000. I would guess because the font is not equal width for each character.
What I would like to do is be able to display the costs just like the are when in an Excel spreadsheet when formatted as Accounting (ie the dollar sign is left hand justified, the numbers are right hand justified and the numbers are lined up from cell to cell).
Example:
$ 10,000.00
$ 11,111.11
If someone knows what formatting to apply to reach this goal please let me know.
This is probably too simple but at a guess I would use fixed font for the cell like "Courier New" so that all the characters are the same width and would align up. The downside of this is that "Courier New" is not the most elegant font to use.
I am sure Excel uses a much more sophisticated mechanism for aligning numeric values.
Maybe you should use something that better mimics a spreadsheet than a table in a flowdocument.

Resources