Excel: Remove part of cell (String) based on another cell (String) - excel

I have two columns/cells that look like this:
Column A
Column B
Word123
Word1 Word12 Word123 Word1234
My question:
How can I remove the "Word123" (value of Column A) inside Column B so that the value of Column B looks like this:
Word1 Word12 Word1234
Note that in Column B there is always one space character betweens these values and I have a lot of rows that need this kind of processing.
I have tried using the SUBSTITUTE Function but that doesnt seem to do the trick

Try the following formula-
=LET(x,TEXTSPLIT(B2,," "),TEXTJOIN(" ",1,FILTER(x,COUNTIFS(A2,x)=0)))

SUBSTITUTE works fine too... But you need to use some extra spaces to separate the strings clearly:
=TRIM(SUBSTITUTE(" " & B1 & " " ; " " & A1 & " " ; " "))

Related

How to create a list of values from cell, separated by certain characters

I have a list that looks something like this
What I want to do is create a formula so in another cell I get the following
'ID1','ID2',ID3','ID4'
It doesn't matter if at the very beginning and at the very end I get extra characters because I can remove those manually, my issue is that in reality this list has hundred of IDs and I can't do this manually.
In next column (assuming data starting in A1):
in B1 = " ' " & A1 & " ' " and drag down (I added spaces to make readable, but you don't want them within the quotes in your actual formuale)
Then in C1 = B1, and in C2 = C1&","&B2, and drag down.

Insert a text string into a specific position of another text string in Excel

If column A lists the following yourusername and column B contains different values such as variant1, variant2, etc. how can I create a formula that results in yourvariant1username yourvariant2username?
If you have
John Apple
Jane Banana
then in column C,
=B1 & A1 will produce
AppleJohn
BananaJane
If you wish to take same username field, you can put $ in front, like $A$1which will keep the same cell reference.
EDIT: based on comment:
(below you may need to replace ";" with "," if you have an English-version of Excel.
Given that there is one distinct character in one column:
Col A Col B Col C
-------- -------------- ------------
1234 analyt+#gmail.com analyt+1234#gmail.com
5678 prefix#gmail.com prefix5678#gmail.com
Col C could be achieved by something like this:
=LEFT(B1;FIND("#";B1)-1 & A1 & RIGHT(B1;FIND("#";B1)-1)
Alternative versions :
Insert after 3 characters
=LEFT(B1;3) & A1 & RIGHT(B1;LENGTH(B1)-3)
If one string always contains "+" or some other marker:
=REPLACE(B1;SEARCH("+#";B1); 2 ; A1 & "+#")
(of if the "+#" string is stored in a cell, like F1) :
=REPLACE(B1;SEARCH( $F$1 ;B1); LENGTH($F$1) ; A1 & $F$1)
(the string to search/replace can of course also be a reference to a cell containing this string)
This should give you enough to build on. If ok, please accept as a solution.

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)

Excel spreadsheet - combine rows in column 1 and 2, 3 and 4 and so on

The only way my client can provide me these addresses is with the location is in one row: Location Name, street address, city.....and then the row below it contains the zip code. This repeats for 1600 lines.
I, of course, need all the info on one line. Is there a genius out there than knows how to make short work of putting the zip code on the line above it?
If you have address in columns A, B and C in the first row and zip code in column A in second row, try the below formula,
=INDEX(A:A,ROW()*2-1,1)&" " &INDEX(B:B,ROW()*2-1,1)& " " & INDEX(C:C,ROW()*2-1,1)& " " &INDEX(A:A,ROW()*2,1)
If you are starting from some other row other than row 1, you may have to modify the formula a little bit. Hope this helps.
Use a formula to combine your columns.
Here we have some test data.
In column D, specify a formula such as =A1 & ", " & B1 & " " & C1
If you're no familiar with formulas, just use "=" to denote the start of one, and then use "&" to concatenate your values.
As for as implementing this on a multi-row basis, you can easily do so. Once you drag your formula down, it'll auto increment the column names unless you specifically specified it not to. I won't get into that right now though.
So what I would do is just add an IF statement in your formula to account for those rows which are not intended to be used. Using a formula such as this: =IF(B1="", "", A1 & ", " & B1 & " " & A2), I can get the following results.

Text to columns with structure: Apple David 1234 5679 2456

I want to separate data in one cell into three cells.
That is, the data structure is
"Fruit Name"+certain spaces+"Name"+certain spaces+"Numbers".
And what I what is
Fruit Name
Name
Numbers
in three separate cells.
I know the built-in function of excel Text to columns can put fixed width to do this function. However, the word may be spitted into two different cells. Ex. Apple > App in one cell and le in another cell.
So, I want functions to do the task.
In F5, I use =mid(E5,1,find(" ",E5)).
However, I do not know how to proceed in G5 and H5 for David and 1236 4566 078 7888.
I appreciate you so much for your help.
Update!
I fixed the formula for column F from the original post because it still included the space after Fruit Name.
The formula for column G finds the spaces on the left of Name and trims them, and finds the next occurrence of a space character to mark the end of Name. And for column H, it finds the value in column G, skips it, then trims the leading spaces.
For column F:
=MID(E1, 1, FIND(" ", E1) - 1)
For column G:
=MID(TRIM(MID(E1, FIND(" ", E1), LEN(E1))), 1, FIND( " ", TRIM(MID(E1, FIND(" ", E1), LEN(E1)))) - 1)
For column H:
=TRIM(MID(E1, FIND(G1, E1) + LEN(G1), LEN(E1)))
This UDF can help you:
Function GetWord(MyString As String, WordNum As Long)
MyString = Trim(Replace(MyString, Chr(32), " "))
Do Until Len(MyString) = Len(Replace(MyString, " ", " "))
MyString = Replace(MyString, " ", " ")
Loop
GetWord = Split(MyString," ")(WordNum - 1)
End Function
Use it like this =GetWord(A1,2) where A1 has your text and 2 is the word number you want to retrieve.

Resources