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.
Related
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 & " " ; " "))
Counting the number of superstrings within a range contain a substring is easy in LibreOffice Calc and Excel. How to count how many times a superstring contains substrings within a range? In the example below, the times an Animal is contained in a set is COUNTIF($A$2:$A$5,""&B2&"") for Dog, COUNTIF($A$2:$A$5,""&B3&"") for Cat and so on. How do I count how many Animals of range B:B are contained in "Cat Dog Mouse Snake"? The answers on column D should be 3, 1, 1, 1.
Place the following formula in D2. It is an array formula so you will need to use Control+Shift+Enter instead of just Enter. You will know you have done it right when { } show up around the formula in the formula bar. Note these cannot be added manually.
=SUM(--NOT(ISERR(SEARCH($B$2:$B$5,A2))))
Copy the cell and then paste in D3:D5.
First put this UDF in a standard module:
Public Function KeyKount(s As String, keywds As Range) As Long
Dim temp As String, cell As Range
KeyKount = 0
temp = " " & s & " "
For Each cell In keywds
v = " " & cell.Text & " "
If InStr(temp, v) > 0 Then KeyKount = KeyKount + 1
Next cell
End Function
Then in a cell enter, for example:
=keykount(A2,B2:B10)
Either:
=SUMPRODUCT(--(ISNUMBER(MATCH(FILTERXML("<a><b>"&SUBSTITUTE(A2," ","</b><b>")&"</b></a>","//b"),B:B,0))))
Or
=SUMPRODUCT(--ISNUMBER(SEARCH(" "&$B$2:$B$5&" "," "&A2&" ")))
Again both work in Excel, not sure about librecalc. The first will do fewer interactions if the string has less words than the lookup list, while the second is the opposite
For LO Calc:
=SUMPRODUCT(ISNUMBER(SEARCH(B$2:B$5;A2)))
The following is able to handle only "No Access" text in the specified cells.
How can I alter them to handle "Covered" & "Damaged" to display "" (null string) if true, else carry on with formulating.
Column G formula
=IF(OR(L18="No Access",$J18="No Access")," ",(L18-$J18)*1000)
Column I, K & M Formula
=IF(H18 = "No Access","No Access",(H18-$C18)*1000)
Column N formula
=IF(M18="No Access", " ",
IF(ABS(M18)>ABS(F18),"Exceeded PD Level",
IF(AND(ABS(M18)>ABS(E18), ABS(M18)<ABS(F18)),"Exceeded Alert Level",
" ")))
As requested, here's the values I need to handle
Column I,K & M are calculated base on the values in the column before them
Column N refer to value in Column M & compares it with value in Column E & F, displaying various messages to if column M hit the range specified.
(Assuming your alter words are these (Please extend below for any more)):
No Access
Covered
Damaged
There where two approaches I have introduced
1. Please correct your formulas in this form:
Column G formula
=IF(OR(L18="No Access",L18="Covered",L18="Damaged",$J18="No Access",$J18="Covered",$J18="Damaged")," ",(L18-$J18)*1000)
Column I, K & M Formula
=IF(OR(H18 = "No Access",H18 = "Covered",H18="Damaged"),"No Access",(H18-$C18)*1000)
Column N formula
=IF(OR(M18="No Access",M18="Covered",M18="Damaged"), " ",
IF(ABS(M18)>ABS(F18),"Exceeded PD Level",
IF(AND(ABS(M18)>ABS(E18), ABS(M18)<ABS(F18)),"Exceeded Alert Level",
" ")))
2. Use this array form formula to handle any more/ other alters easier:
Follow these 3 steps
Use a helper column, for example column X (It can be hided), and
enter all of your alter words in this column.
Create a Name (Ctrl + F3), for example
Alters and set Refers to field to your helper column range. (for example $X$1:$X$10)
Write this formula in appropriated cells and then press
Alt + Ctrl + Enter to running formula against pressing Enter
Column G formula
=IF(OR(L18=Alters,$J18=Alters)," ",(L18-$J18)*1000)
Column I, K & M Formula
=IF(H18 = Alters,"No Access",(H18-$C18)*1000)
Column N formula
=IF(M18=Alters, " ",
IF(ABS(M18)>ABS(F18),"Exceeded PD Level",
IF(AND(ABS(M18)>ABS(E18), ABS(M18)<ABS(F18)),"Exceeded Alert Level",
" ")))
In this brief form you can Edit, Add or Remove any Alter words as you want in your helper column.
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.
is possible to get results from columns A-E into column H without use of VBA?
Do you have any suggestions how to do it? Thank you
It needs to look at the row above, so you need to paste it on row 2 and drag from there. On row 1 you will have a ref error but it will still work. For the future you may want to add an extra empty row at the top and have the formula in H2 and down.
H2:
=IF(COUNT(A2:E2)=0,H1,IF(A2<>"",A2&".",LEFT(H1,FIND("|",SUBSTITUTE(H1,".","|",MATCH(TRUE,INDEX(A2:E2<>"",0),0)-1),1))&INDEX(A2:E2,1,MATCH(TRUE,INDEX(A2:E2<>"",0),0))&"."))
I know it looks like a mess, but I'll try to explain it:
IF(COUNT(A2:E2)=0,H1
This is for the empty rows. if empty use the one above
IF(A2<>"",A2&"."
if A2 has a value start with completely new text
INDEX(A2:E2<>"",0)
returns an array of true/false for if the cells are empty
MATCH(TRUE,INDEX(A2:E2<>"",0),0)
This gives you the columnnumber with the new data
SUBSTITUTE(H1,".","|",MATCH...)
Repleces the n-th dot with a | This is so we can use Find to figure out how much of the text above to keep.
INDEX(A2:E2,1,MATCH(TRUE,INDEX(A2:E2<>"",0),0))
is the new data
You can do this by building up the target in a set of columns that can be hidden.
Following from your example above, if you add columns I, J, K and L, use the following formulae:
Cell I1: =A1 & "."
Cell J1: =IF(B1="","",B1 & ".")
Cell K1: =IF(C1="","",C1 & ".")
Cell L1: =IF(D1="","",D1 & ".")
All other rows:
Column I: =IF(A2="",I1,A2 & ".")
Column J: =IF(B2="",IF(I2=I1,J1,""),B2 & ".")
Column K: =IF(C2="",IF(J2=J1,K1,""),C2 & ".")
Column L: =IF(D2="",IF(K2=K1,L1,""),D2 & ".")
Then set column H to be:
=I1 & J1 & K1 & L1 & M1
This roughly translates as "If there isn't a new number, use the number from the row above, unless the parent number has changed, in which case use a blank."
You can hide columns I, J, K and L, or just use alternative columns further to the right if these are not available.