I have a column with about 5k rows that I need to add slashes to. I need to add slashes to the first, second, and last space (" ") in the cell. Each cell has different lengths so there are different amounts of spaces between the second and last in each row.
Here's an example of some rows
NYLA D DURA FEMUR BCN LG
NULO D FZD GF BF 5oz
OMNI D BRTSH SLP LD GRN 4ft
OMNI D LIGHT S-HOOK
OMNI D SS BOWL 3qt
I need these converted to
NYLA/D/DURA FEMUR BCN/LG
NULO/D/FZD GF BF/5oz
OMNI/D/BRTSH SLP LD GRN/4ft
OMNI/D/LIGHT S-HOOK
OMNI/D/SS BOWL/3qt
I have tried using the substitute formula but that will only add one slash when I need to add 1-3. I'm not sure if nesting the substitute formula is possible in this scenario. If so, that should do it but I can't get it to work.
Nested SUBSTITUTE is the way to go:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1," ","/",LEN(A1)-LEN(SUBSTITUTE(A1," ","")))," ","/",2)," ","/",1)
You can achieve this with the following formula:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1," ","/",LEN(SUBSTITUTE(A1," "," "))-LEN(A1))," ","/",1)," ","/",1)
It replaces the last instance of " " followed by the first two instances.
This might however return an error if there are less than three " " in the string.
Related
I am trying to bring together several cells and they have a specific length so if I have
A1 needs to be 5 chars and the value is 'cat'
B1 needs to be 6 chars and the value is 'dog'
Concatenated it would be:
[space space]cat[space space space]dog
or
" cat dog"
I'm having trouble finding a function or set of functions that allows this, most want to trim out leading or trailing spaces.
Yes:
=CONCATENATE(RIGHT(REPT(" ",5)&A1,5),RIGHT(REPT(" ",6)&A2,6))
or as #BigBen stated use & instead of Concatenate:
=RIGHT(REPT(" ",5)&A1,5)&RIGHT(REPT(" ",6)&A2,6)
I have dummy emails that are too long. I want to shorten them but I don't want to delete the first parenthesis.
"est#scelerisque.ca"
"fermentum#fringillacursus.edu"
"adipiscing#arcuVivamussit.com"
"vitae.aliquet#Sed.edu"
"magna.tellus#Nullamnisl.com"
"placerat.eget#purusNullam.org"
Is it possible for me to delete for example the first 3 letters after the (") and the next 3 letters after # and stop at the dot?
As i ask this, it sounds really complicated. I may just use the same email for all users since it's just dummy data :/
If you have one email in each cell, you can create an excel formula which will
convert email values for you.
Delete 3 letters after ":
=CHAR(34) & MID(A1, 5, LEN(A1))
(Using result of previous formula in B1):
Skip 3 letters after #:
=MID(B1, 1, FIND("#", B1)) & (MID(B1, FIND("#", B1)+4, LEN(B1)))
(Using result of previous formula in C1):
Stop at the dot (also keep " at the end):
=MID(C1, 1, FIND(".",C1)-1 ) & CHAR(34)
I'm debugging some ColdFusion code (although the question is really language-agnostic), and from the debug output, have two columns of text.
Those columns are field name <tab> value and want to be able to quickly convert this into test code.
The text I start off with:
a 1
b 2
c 3
etc
The code I want to end up with:
structInsert(myStruct, "a", 1);
structInsert(myStruct, "b", 2);
structInsert(myStruct, "c", 3);
etc
Ordinarily, I'd use Excel, pasting the two columns of data into columns A and B, and create a formula in column C that concatenates A and B something like
="structInsert(myStruct, """ & A1 & """, " & B1 & ");"
This works fine (and is one of the main reasons I love Excel).
But I'm wondering... given that the whole world doesn't have Excel, how does everyone else do this?
Thanks!
Well I like to do with Notepad++ or Eclipse with search and replace feature with regular expression.
Like search for
([a-z]*)\t(\d)
replace with
structInsert(myStruct,"\1",\2);
So simple.. right?
You could do this with regular expressions.
In CFEclipse/CFBuilder open the Find/Replace dialogue
Find: ^(.+?)\t(.+?)$
Replace with: structInsert(myStruct, "$1", $2);
Check Regular Expressions
Click Replace All
I have an error in this excel formula and I can't just figure it out:
=LEFT(B3,FIND(",",B3&",")-1)&","&RIGHT(B3,LEN(B3)-FIND("&",B3&"&")),RIGHT(B3,LEN(B3)-SEARCH("#",SUBSTITUTE(B3," ","#",LEN(B3)-LEN(SUBSTITUTE(B3," ",""))))&", "&SUBSTITUTE(RIGHT(B3,LEN(B3)-FIND("&",B3&"&")-1),RIGHT(B3,LEN(B3)-SEARCH("#",SUBSTITUTE(B3," ","#",LEN(B3)-LEN(SUBSTITUTE(B3," ",""))))),""))
It may seem like a big formula, but all it's intended to do is if no ampersand is in a cell, return an empty cell, if no comma but ampersand exists, then return this, for example:
KNUD J & MARIA L HOSTRUP
into this:
HOSTRUP,MARIA L
Otherwise, there is no ampersand but there is a comma so we just return: LEFT(A1,FIND("&",A1,1)-1).
Seems basic, but formula has been giving me error message and doesn't point to the problem.
Your error is here:
=LEFT(B3,FIND(",",B3&",")-1)&","&RIGHT(B3,LEN(B3)-FIND("&",B3&"&")),
At this point, the comma doesn't apply to anthing, because the right operator has matching parens
As far as what you want? Let's break that up into what you actually asked for:
if no ampersand in a cell, return empty cell,
B4=Find("&", B3&"&")
B5=IF(B4>LEN(B3),"",B6)
if no comma but ampersand exists
B6=IF(FIND(",", B3&",")>LEN(B3),B8,B7)
then turn this, for example:
KNUD J & MARIA L HOSTRUP
into this:
HOSTRUP,MARIA L
I'm presuming you mean to put the last whole word? Let's mark the last whole word:
B9=SUBSTITUTE(B3," ","#",LEN(B3)-LEN(SUBSTITUTE(B3," ","")))
B10=RIGHT(B7,LEN(B9)-FIND("#",B9))
And the stuff between the ampersand and the last word
B11=TRIM(MID(B9,B4 + 1, LEN(B9)-FIND("#",B9)-1))
Then calculating it is easy
B7=B10&","&B11
Otherwise, there is no ampersand but there is a comma so we just return:
LEFT(A1,FIND("&",A1,1)-1).
Well, if you want that, let's just put that in B8
B8=LEFT(A1,FIND("&",A1,1)-1)
(But I think you actually mean B3 instead of A1)
B8=LEFT(B3,FIND("&",B3,1)-1)
And there you have it (B5 contains the information you're looking for) It took a few cells, but it's easier to debug this way. If you want to collapse it, you can (but doing so is more code, because we can reduce duplication by referencing a previously calculated cell on more than one occasion).
Summary:
B3=<Some Name with & or ,>
B4=FIND("&", B3&"&")
B5=IF(B4>LEN(B3),"",B6)
B6=IF(FIND(",", B3&",")>LEN(B3),B7,B8)
B7=B10&","&B11
B8=LEFT(B3,FIND("&",B3,1)-1)
B9=SUBSTITUTE(B3," ","#",LEN(B3)-LEN(SUBSTITUTE(B3," ","")))
B10=RIGHT(B9,LEN(B9)-FIND("#",B9))
B11=TRIM(MID(B9,B4 + 1, LEN(B9)-FIND("#",B9)-1))
When I put in "KNUD J & MARIA L HOSTRUP", I get "HOSTRUP,MARIA" in B5.
I have a set of data that shown below on excel.
R/V(208,0,32) YR/V(255,156,0) Y/V(255,217,0)
R/S(184,28,16) YR/S(216,128,0) Y/S(209,171,0)
R/B(255,88,80) YR/B(255,168,40) Y/B(255,216,40)
And I want to separate the data in each cell look like this.
R/V 208 0 32
R/S 184 28 16
R/B 255 88 80
what is the function in excel that I can use for this case.
Thank you in advance.
kennytm doesn't provide an example so here's how you do substrings:
=MID(text, start_num, char_num)
Let's say cell A1 is Hello.
=MID(A1, 2, 3)
Would return
ell
Because it says to start at character 2, e, and to return 3 characters.
In Excel, the substring function is called MID function, and indexOf is called FIND for case-sensitive location and SEARCH function for non-case-sensitive location. For the first portion of your text parsing the LEFT function may also be useful.
See all the text functions here: Text Functions (reference).
Full worksheet function reference lists available at:
Excel functions (by category)
Excel functions (alphabetical)
Another way you can do this is by using the substitute function. Substitute "(", ")" and "," with spaces.
e.g.
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1, "(", " "), ")", " "), ",", " ")
I believe we can start from basic to achieve desired result.
For example, I had a situation to extract data after "/". The given excel field had a value of 2rko6xyda14gdl7/VEERABABU%20MATCHA%20IN131621.jpg . I simply wanted to extract the text from "I5" cell after slash symbol. So firstly I want to find where "/" symbol is (FIND("/",I5). This gives me the position of "/". Then I should know the length of text, which i can get by LEN(I5).so total length minus the position of "/" . which is LEN(I5)-(FIND("/",I5)) . This will first find the "/" position and then get me the total text that needs to be extracted.
The RIGHT function is RIGHT(I5,12) will simply extract all the values of last 12 digits starting from right most character. So I will replace the above function "LEN(I5)-(FIND("/",I5))" for 12 number in the RIGHT function to get me dynamically the number of characters I need to extract in any given cell and my solution is presented as given below
The approach was
=RIGHT(I5,LEN(I5)-(FIND("/",I5))) will give me out as VEERABABU%20MATCHA%20IN131621.jpg . I think I am clear.
Update on 11/30/2022
With new excel functions, you can use the following in cell C1 for the input in A1:
=TEXTJOIN(" ",,TEXTSPLIT(A1,{"(",",",")"}))
Here is the output:
What about using Replace all?
Just replace All on bracket to space.
And comma to space. And I think you can achieve it.