I have Name and Address column in excel looks like a
I want to take City name and Pincode in separate columns like
Secunderabad 500094
warangal 506005
warangal 506005
Is it possible to do in excel? or is there any option for this please let me know
If all are separated with a hyphen, "-", then you could use the Left and Right functions as follows:
=LEFT(A1, FIND("-",A1) - 1)
and
=RIGHT(A1, LEN(A1) - FIND("-",A1))
where A1 is the cell with city and code together, and the Left formula gets the city and the Right formula gets the code.
EDIT
Assuming each cell has CITY- and PHNO- to set off the positions of each, then you could do something like the following.
Get city name:
=TRIM(MID(A1, FIND("CITY-",A1) + 5, FIND("-", A1, FIND("CITY-",A1) + 5) - FIND("CITY-",A1) - 5))
Get code:
=TRIM(MID(A1, FIND("-", A1, FIND("CITY-",A1) + 5) + 1, FIND("PHNO-",A1) - FIND("-", A1, FIND("CITY-",A1) + 5) - 1))
Get phone number:
=RIGHT(A1, LEN(A1) - FIND("PHNO-",A1) - 4)
If a cell doesn't contain a PHNO- or a CITY-, then the formulas will not work.
Related
I need help to do this.
I have on:
A1 cell "Portugal + Spain + UK + Belgium"
B1 cell " France + Germany + Spain + italy"
And i want on D1 the common word on a1 and b2. in this example "spain"
is this possible?
tks
I would use "Text to Columns" like described here. Next I would use the formula =FILTER(list1,COUNTIF(list2,list1))
So consider that list1 is in cells A1:D1 and list2 is in cells A2:D2
the next cell (what ever cell) would have the formula:
=FILTER(A1:D1,COUNTIF(A2:D2,A1:D1))
I've looked at documentation and think the following would be supported within Excel 2021:
=LET(x,FILTERXML("<t><s>"&SUBSTITUTE(A1,"+","</s><s>")&"</s></t>","//s"),TEXTJOIN(" + ",,FILTER(x,ISNUMBER(FIND("+ "&x&" +","+ "&B1&" +")),"")))
Or, if you would be interested in a xpath based solution:
=TEXTJOIN(" + ",,FILTERXML("<x><t>"&TEXTJOIN("</s></t><t>",,FILTERXML("<t><s>"&SUBSTITUTE(A1,"+","</s><s>")&"</s></t>","//s")&"<s>+ "&B1)&" +</s></t></x>","//t[.//*[contains(.,concat('+ ',../text(),' +'))]]"))
I have tried & I got the below ans..
in Cell D3
=FILTER(TEXTSPLIT(TEXTJOIN(" + ",,A3:B3)," + "),TEXTSPLIT(TEXTJOIN(" + ",,A3:B3)," + ")=C3)
with the Filter function the result will be array.
and the basic result which supports all versions of excel is
in Cell D3
=IFERROR(MID($A3&" + "&$B3,SEARCH("#",SUBSTITUTE($A3&" + "&$B3,$C$3,"#",COLUMNS($D3:D3))),LEN($C$3)),"-")
have to drag the formula right side until get the result "-".
I want to extract the two specific words from excel cell ie: cell A1 contains data
{"defvcision":"DISASDEE","reascdwon":"labwcel","cowcddcents":"SwcA:Ercwdcror:CwcOwccPcewS:SewellerApcwecpewcal-BwerLR:2/24/2020 : 306973918 # snedcharo"}
Now I want to extract 306973918 and snedcharo from cell. These to values will be dynamic in other cells ie A2 A3...
I have tried formula
=MID(A1, SEARCH(":",A1) + 1, SEARCH(":",A1,SEARCH(":",A1)+1) - SEARCH(":",A1) - 1)
but that is not working.
if all the cells are kinda the same format you can also use text to columns on this cell with delimited and space and your number will be on "C" column
The easiest would be to use UDF.
In order to define UDF you need to write simple function in worksheets module, like in below picture:
Then you can use it in worksheet like below:
Below is the function code, which you can adjust to your needs:
Function ExtractText(text As String)
text = StrReverse(text)
colonIdx = InStr(1, text, ":")
apostropheIdx = InStr(1, text, """")
text = Mid(text, apostropheIdx + 1, colonIdx - apostropheIdx - 2)
ExtractText = StrReverse(text)
End Function
In A2, formula copied down to A3 :
=TRIM(LEFT(RIGHT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A$1,"""}","")," #","")," ",REPT(" ",99)),(3-ROW(A1))*99),99))
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.
I have (500+rows 20+ columns) sheet and some cells having data as shown below:
To extract the text into columns do something like this
Enter this formula to extract first line
=LEFT(A1, SEARCH(CHAR(10),A1,1)-1)
to extract middle line
=MID(A1, SEARCH(CHAR(10),A1) + 1, SEARCH(CHAR(10),A1,SEARCH(CHAR(10),A1)+1) - SEARCH(CHAR(10),A1) - 1)
to extract last line
=RIGHT(A1,LEN(A1) - SEARCH(CHAR(10), A1, SEARCH(CHAR(10), A1) + 1))
Select Column A
Go to Ribbon
Data -> Text to Columns
check "Delimited", click Next
check "Other", enter the character "/" in the box next to Other:
click Finish
How can I append text to every cell in a column in Excel? I need to add a comma (",") to the end.
Example:
email#address.com turns into email#address.com,
Data Sample:
m2engineers#yahoo.co.in
satishmm_2sptc#yahoo.co.in
threed_precisions#rediffmail.com
workplace_solution#yahoo.co.in
threebworkplace#dataone.in
dtechbng#yahoo.co.in
innovations#yahoo.co.in
sagar#mmm.com
bpsiva#mmm.com
nsrinivasrao#mmm.com
pdilip#mmm.com
vvijaykrishnan#mmm.com
mrdevaraj#mmm.com
b3minvestorhelpdesk#mmm.com
sbshridhar#mmm.com
balaji#mmm.com
schakravarthi#mmm.com
srahul1#mmm.com
khramesh2#mmm.com
avinayak#mmm.com
rockindia#hotmail.com
See if this works for you.
All your data is in column A (beginning at row 1).
In column B, row 1, enter =A1&","
This will make cell B1 equal A1 with a comma appended.
Now select cell B1 and drag from the bottom right of cell down through all your rows (this copies the formula and uses the corresponding column A value.)
Select the newly appended data, copy it and paste it where you need using Paste -> By Value
That's It!
It's a simple "&" function.
=cell&"yourtexthere"
Example - your cell says Mickey, and you want Mickey Mouse. Mickey is in A2. In B2, type
=A2&" Mouse"
Then, copy and "paste special" for values.
B2 now reads "Mickey Mouse"
It's simple...
=CONCATENATE(A1, ",")
Example: if email#address.com is in the A1 cell then write in another cell: =CONCATENATE(A1, ",")
email#address.com After this formula you will get email#address.com,
For remove formula: copy that cell and use Alt + E + S + V or paste special value.
There is no need to use extra columns or VBA if you only want to add the character for display purposes.
As this post suggests, all you need to do is:
Select the cell(s) you would like to apply the formatting to
Click on the Home tab
Click on Number
Select Custom
In the Type text box, enter your desired formatting by placing the number zero inside whatever characters you want.
Example of such text for formatting:
If you want the cell holding value 120.00 to read $120K, type $0K
Pretty simple...you could put all of them in a cell using the concatenate function:
=CONCATENATE(A1, ", ", A2, ", ", and so on)
Highlight the column and then Ctrl + F.
Find and replace
Find ".com"
Replace ".com, "
And then one for .in
Find and replace
Find ".in"
Replace ".in, "
Simplest of them all is to use the "Flash Fill" option under the "Data" tab.
Keep the original input column on the left (say column A) and just add a blank column on the right of it (say column B, this new column will be treated as output).
Just fill in a couple of cells of Column B with actual expected output. In this case:
m2engineers#yahoo.co.in,
satishmm_2sptc#yahoo.co.in,
Then select the column range where you want the output along with the first couple of cells you filled manually ... then do the magic...click on "Flash Fill".
It basically understands the output pattern corresponding to the input and fills the empty cells.
I just wrote this for another answer:
You would call it using the form using your example: appendTextToRange "[theRange]", ",".
Sub testit()
appendTextToRange "A1:D4000", "hey there"
End Sub
Sub appendTextToRange(rngAddress As String, append As String)
Dim arr() As Variant, c As Variant
arr = Range(rngAddress).Formula
For x = LBound(arr, 1) To UBound(arr, 1)
For y = LBound(arr, 2) To UBound(arr, 2)
Debug.Print arr(x, y)
If arr(x, y) = "" Then
arr(x, y) = append
ElseIf Left(arr(x, y), 1) = "=" Then
arr(x, y) = arr(x, y) & " & "" " & append & """"
Else
arr(x, y) = arr(x, y) & " " & append
End If
Next
Next
Range(rngAddress).Formula = arr
End Sub
Select the range of cells, type in the value and press Ctrl + Enter.
This, of course, is true if you want to do it manually.
Put the text/value in the first cell, then copy the cell, mark the whole colum and 'paste' the copied text/value.
This works in Excel 97 - sorry no other version available on my side...
This is addition to #Edward-Leno 's answer for more detail/explanation and cases where the text cells are formulas instead of values, and you want to retain the original formula.
Suppose your cells look like this (formulas)
="email" & "#" & "address.com"
=A1 & "#" & C1
instead of this (values)
email#address.com
If "email" and "address.com" were some cells like A1 is the email and C1 is the address.com part, then you'd have something like =A1&"#"&C1 which would be important to retain since A1 and C1 might not be constants and can change, so the comma-concatenated values would change, like if C1 is "gmail.com", "yahoo.com", or something else based on its formula.
Values method: The following steps will successfully append text but only keep the value using a scratch column (this works for rows, too, but for simplicity, the directions are for columns)
Assume column A is your data.
In scratch column B, start anywhere like the top of column B such as at B1 and put this formula:
=A1&","
Essentially, the "&" is the concatenation operator, combining two strings together (numbers are converted to strings). The "," can be adjusted to ", " if you want a space after the comma.
Copy the cell B1 and copy it down to all other cells in column B, either by clicking at the bottom right of cell B1 and dragging down, or copying with "Ctrl+C" or right-click > "Copy".
Paste B1 to all cells in column B with "Ctrl+V" or right-click > "Paste Options:" > "Paste". You should see the data looking like you intended.
Copy all cells in column B and paste them to where you want via right-click > "Paste Options:" > "Values". We select values so it doesn't mess up any formatting or conditional formatting
Formula retention method: The following steps will successfully retain the original formula. The process is similar to the values method, and only step 2, the formula used to concatenate the comma, changes.
Assume column A is your data.
In scratch column B, start anywhere like the top of column B such as at B1 and put this formula:
=FORMULATEXT(A1)&","
FORMULATEXT() grabs the formula of the cell as opposed to the value of it, so a simple example would be that it grabs =2+2 instead of 4, or =A1 & "#" & C1 where A1 is "Bob" and C1 is "gmail.com" instead of Bob#gmail.com.
Note: This formula only works for Excel versions 2013 and greater. For alternative equivalent solutions for Excel 2010 and older, see this superuser answer: https://superuser.com/a/894441/495155
Copy the cell B1 and copy it down to all other cells in column B, either by clicking at the bottom right of cell B1 and dragging down, or copying with "Ctrl+C" or right-click > "Copy".
Paste B1 to all cells in column B with "Ctrl+V" or right-click > "Paste Options:" > "Paste". You should see the data looking like you intended.
Copy all cells in column B and paste them to where you want via right-click > "Paste Options:" > "Values". We select values so it doesn't mess up any formatting or conditional formatting
Type it in one cell, copy that cell, select all the cells you want to fill, and paste.
Alternatively, type it in one cell, select the black square in the bottom-right of that cell, and drag down.