test for empty cell and then convert number text - text

I have always had a problem importing phone numbers from CSV files into Outlook. Now I am working with Excel to clean up the telephone fields which should be in +1 545 254-2351 format.
I need to first test to see if the cell is empty containing the telephone number and if false to convert the contents of the cell to TEXT. I have written the following formula to no avail.
=IFS(ISBLANK(A5),"",ISTEXT(A5),A5,TEXT(A5,0))
In theory if A5 is blank it will return a blank cell. If it is not blank then if A5 is TEXT the result will be just A5. If it is not text i.e. a number, then it converts a5 to text.
This does not work. Can someone help me with this?

If we assume that A5 can contain either:
Text like: +1 545 254-2351
blank
Number like: 15452542351
Then in B5 enter:
=IF(ISBLANK(A5),"",IF(ISTEXT(A5),A5,("+" & LEFT(TEXT(A5,"#"),1) & " ") & MID(TEXT(A5,"#"),2,3) & " " & MID(TEXT(A5,"#"),5,3) & "-" & RIGHT(TEXT(A5,"#"),4)))

Related

Excel Formula to display text based on value of two cells

Im looking for a way to display text of a cell based on the below two conditions :
If Cell C20 contains certain words like "ghan", "ERC", "VSL" AND cell D22 is <> "-" then cell i22 should display the content of cell C20.
If cell C20 does not contain any of these words regardless whether D22 is ="-" or contains a number it should remain as "-"
Screenshot attached
Here's what i have tried so far :
1) =IF(AND(ISNUMBER(Aug!I555),ISNUMBER(SEARCH("ERC",Aug!B555))),Aug!B555,"-")
2) =IF(ISNUMBER(Aug!I596),Aug!B596,IF(ISNUMBER(SEARCH("*ERC*",Aug!B596)),Aug!B596,"-"))
This is what im using for now as a temporary solution
3) =IF(D22<>"-",IF(ISNUMBER(SEARCH("ghantoot",C20)),C20,IF(ISNUMBER(SEARCH("sand",C20)),C20,IF(ISNUMBER(SEARCH("vsl",C20)),C20,IF(ISNUMBER(SEARCH("wet",C20)),C20,"-")))))
In I22:
=IF(ISNUMBER(D22),
IF(OR(ISNUMBER(SEARCH("ghan",C20)),
ISNUMBER(SEARCH("ERC",C20)),
ISNUMBER(SEARCH("VSL",C20))),
C20,
"-"),
IF(D22="-","-","d22 not number & not -"))
I don't think you stated what happens with all branches of the logic, so I have put placeholder text there for you to fill in yourself. This is:
"d22 not number & not -"

Checking contents of cell for contents of another cell

I'm trying to compare the contents of pairs of horizontally adjacent cells in excel.
Column A contains text formatted as a list (abc, def, ghi, jkl) and column B contains one of the elements of the list (abc). How would I search the contents of cells in column A for the exact text of cells in column B?
I don't have enough reputation to include an image in my post but I hope the question is clear enough. Thanks in advance!
[A2] = abc, def, ghi,jkl
[B2] = def
[C2] ="," & SUBSTITUTE(A2," ","") & ","
[D2] =FIND(TRIM(B2),C2)
[E2] =FIND(TRIM(B2),"," & SUBSTITUTE(A2," ","") & ",")
[F2] =IFERROR(FIND(TRIM(B2),"," & SUBSTITUTE(A2," ","") & ","),0)
[Final] =IF(IFERROR(FIND(TRIM(B2),"," & SUBSTITUTE(A2," ","") & ","),0), "Found", "Not found")
In C2 all blanks are removed and a comma added before and after the string. This revised string is tested in D2.
E2 sees the reference to C2 (in D2) replaced with the formula from C2.
F2 embeds the ready formula in an IFERROR function so that it returns 0 if no match is found.
By this method the formula returns either a number, a character position where a match was found) or 0. [Final] embeds the entire formula in an IF statement which converts the result to something you can use.
For testing and studying just copy A2 :F2 from above to a blank worksheet and place the final formula anywhere, perhaps G2. From there it can be copied down as required. C2:F2 are just for explanation and not required for the [Final] to function.
Edit
The above will find the string "abc" in "abcd". To prevent that please modify the search string as follows.
[D2] =FIND("," & TRIM(B2) & ",",C2)
and the final
[Final] =IF(IFERROR(FIND("," & TRIM(B2) & ",","," & SUBSTITUTE(A2," ","") & ","),0), "Found", "Not found")

How to find a specific number in a string of numbers in Excel

I am looking for help with a formula in Excel to find a specific number in a string of numbers.
Our accounting system pulls a report showing numbers from 1 to 10 and each line can have numerous numbers listed in the cell, each separated with a ";".
What I want to do is create a formula that allows me to simply look for the number in columns O to X (row 3) and fill that number in the corresponding cell.
So starting from row 4, I would like to create a formula that finds each number in the string and simply fills in the one I am looking for in each cell, for example I would like the end result to look like the below example:
If the number doesn't appear then that column is left blank, but if it is found it simply adds itself into the corresponding column.
Hopefully someone out there can help me with this.
Regards;
Greg
formula in B3
in German:
=WENN(ISTFEHLER(FINDEN(";" & B$2 & ";"; ";" & $A3 & ";"));"";B$2)
in English:
=IF(ISERROR(FIND(";" & B$2 & ";" , ";" & $A3 & ";")),"",B$2)
Try this in cell O4:
=IF(NOT(ISERROR(SEARCH(O$3,$N4,1))),O$3,"")
Notes:
Assumes your numbers 1 to 10 are in row 3 (i.e O3:X3)

How to check if a excel cell contains a word

I am looking for an excel formula that either counts or returns true if the cell contains a word pattern (basically wanted to know if any such cell exists), but formula shall recognize a cell as valid only if
Requirement 1 : complete word pattern to be present and as a single word in the cell being checked(Eg: if ab12 is pattern, ab123 is not valid, only ab12 is valid)
Requirement 2 : the matching word can be either in the beginning or end or in middle of the cell being checked
Requirement 3 : The input cell(s) being checked may contain this matching word and can contain prefix/suffix as " "(space) or a line break/feed . Hence, the formula shall identify this cell as valid for both these scenarios
Example word pattern : ab-1_cd_1234
At the moment I have tried both formulas below (also tried with " ","*","~" in the criteria) but didnt work :
Formula 1 : =ISNUMBER(SEARCH(A2,B2))
Here, A2 is the pattern, B2 is the input to verify and will be verified in full B column
Formula 2 : =COUNTIF($B:$B, "* " &A2& " *")
Here, B:B is the input column and A2 is the pattern
Also, I got to know that there is a wildcard in word < and > that defines a word beginning and end, but the same didnt work in excel.
So, it would be great if I can get any formula that works in excel
You can try following formula:
=SUMPRODUCT(--($A$2=FILTERXML("<a><b>" & SUBSTITUTE(SUBSTITUTE(B2,CHAR(10),"</b><b>")," ","</b><b>") & "</b></a>","//b")))>0
Edit
To solve problem with empty strings:
=SUMPRODUCT(--($A$2 & "#"=FILTERXML("<a><b>" & SUBSTITUTE(SUBSTITUTE(B2,CHAR(10),"#</b><b>")," ","#</b><b>") & "#</b></a>","//b")))>0
Edit 2:
To count number of cells which contains pattern you can use array formula:
=SUMPRODUCT(--(IFERROR(SEARCH(" " & A2 & " "," " & SUBSTITUTE($B$2:$B$10,CHAR(10)," ") & " "),0)>0))
Array formula after editing is confirmed by pressing ctrl + shift + enter
Please try this formula, where A3 is a text to be searched and the text to be found is in A1.
=IF(ISERROR(FIND(" "&$A$1&" "," "&SUBSTITUTE(A3,CHAR(10)," ")&" ")),"",TRUE)

Put in one field, values from other fields in one row with some extra text EXCEL

I have situation like his
Text Number Letter Color
empty 1 A Blue
I want to put vales from Number, Letter and Color in Text field to look like this:
Text Number Letter Color
Number is: 1 1 A Blue
Letter is: A
Color is: Blue
How to put all this value from other fields with some extra text into one field in excel?
use
="Number is: " & B2 & char(10) & "Letter is: " & C2 & Char(10) & "Color is: " & D2
Make sure WrapText is enabled.
If you have TEXTJOIN then you can use this array:
=TEXTJOIN(CHAR(10),,$B$1:$D$1 & " is: " & B2:D2)
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when Exiting edit mode.
TEXTJOIN was introduced with Office 365 Excel
To do in separate cells put this in the first cell:
=INDEX($B$1:$D$1,,ROW(1:1)) & " is: " & INDEX($B$2:$D$2,,ROW(1:1))
And copy down.
Excel Method
Use the formula =INDEX($C$1:$E$1,,ROW(1:1)) & " is: " & INDEX($C$2:$E$2,,ROW(1:1)) INSIDE EACH Cell you want it to copy the data from.
GOOGLE SHEET METHOD
You can use the formula: ={{"Number is: ", C2}; {"Letter is: ", D2}; {"Color is: ", E2}} In any 1 cell. Giving you this.

Resources