I have these data in Google Sheets
$71,675_x000d_
$80,356_x000d_
$107,361_x000d_
$123,393_x000d_
$116,878
I want them to be split into different columns.
However, when I do so using Data > Split Data into Different Columns, it separates $71 and 675_x000d_ but I need the $71,275 and remove the xoood
Please note that the last number doesn't have those extra characters.
Please help.
Your post says you want to "remove the x000d (that is, extract only the dollar amounts). That said, let's say your raw data starts in A2 (i.e., the data is in A2:A). Place the following formula into the first cell of another otherwise empty column (e.g., B1):
=ArrayFormula({"Extracted";IF(A2:A="",,REGEXEXTRACT(SUBSTITUTE(A2:A&"_",",",""),"\d+"))})
How It Works:
ArrayFormula(...) signifies that we'll be processing an entire range and not just one cell.
The outer curly brackets {...} signify that a virtual array will be formed from non-like or non-contiguous pieces.
The first piece of the virtual array is the header. Here, that is "Extracted"; but you can change it as you like.
The semicolon means "place the next information below the previous part."
IF(A2:A="",, ...) is a standard check that basically says "Don't try to process any blank cells in Column A"; or alternatively worded, "If any cell in A2:A is blank/null, do nothing."
Skipping the REGEXEXTRACT for now, A2:A&"_" appends an underscore to every entry in A2:A. This allows entries in A2:A that are just a dollar amount (e.g., from the post, $116,878) to have a consistent symbol following them if not already there. (And adding the underscore to anything that already has an underscore won't matter, because we won't be extracting that far out.)
Now that we've got the new strings, we SUBSTITUTE every comma for a null (i.e., delete all commas).
Finally, REGEXEXTRACT will take all of the virtually modified strings and extract \d+, which means only digits (\d) in an unbroken sequence of any length greater than 0 (+). Note that REGEXEXTRACT will only return the first such match it encounters as written, so 000 will not be extracted.
An IFERROR wrap is placed around the REGEXEXTRACT, just in case you have any situations in real life that don't have any sequence of numbers at all. In these cases, nothing will be returned (whereas, without the IFERROR, an error would have been returned).
Once the extraction is done, you can apply Format > Number > Currency (rounded) to the entire column.
Addendum:
After an additional comment (below), it appears that the raw data is in Column T, that all five entries are in one cell and that the OP would like all five amounts extracted across each row. That being the case, assuming that Columns U:Y are empty to start, place the following in cell U1 (not U2):
=ArrayFormula({"Va11","Val2","Val3","Val4","Val5";IF(T2:T="",,IFERROR(REGEXEXTRACT(SUBSTITUTE(T2:T&"_",",",""),REPT("\$(\d+)[^\$]*",5))))})
This works much the same way as the previous formula. The differences:
There are five headers now.
You'll see REPT(...,5) here. This is an easy way to repeat the same extraction five times.
That repeated extraction is now the following:
\$(\d+)[^\$]*
The backslash in front of the dollar signs means to treat those symbols as literals instead of as their usual meaning (i.e., end-of-string). So the extraction reads as follows:
\$ anything that starts with a dollar sign
(\d+) extract what is between the ( ), which is any group of digits [^$]*` followed by any number (including 0) characters that are not dollar signs
As I said, the REPT will repeat this five times; so five groups matching this pattern will be extracted.
Understand that if you have any groups that don't follow the pattern exactly, resulting in five matching extractions, nothing will be returned.
Be sure to format U:Y as currency rounded, or you will wind up with some of those numbers translating as raw dates and therefore being completely off.
Please use the following formula and format cells to your needs.
=ArrayFormula(IFERROR(SPLIT(REGEXREPLACE(A2:A,"\n|_x000d_","โ"),"โ")))
The big advantage of the above formula compared to others is that it works for any number of lines included within a single cell (as shown in the image below).
Functions used:
ArrayFormula
IFERROR
SPLIT
REGEXREPLACE
You can use SPLIT function:
=ArrayFormula(IF(LEN(A:A),SPLIT(A:A,"_x000d_",FALSE),""))
I'm using Google Spreadsheet to make some calculations.
At the bottom of my table I need SUM, AVG and some others and everything is fine.
But I made a long cell with all the text, like this:
="Hi at all, this is my report: "&SUM(B:B)&" are the sum of my fingers, "&AVG(C:C)&" is the avg of my sons."
and so on.
Everything works. But I need to bold the SUM(B:B).
I won't use single cells for math results.
I tried with ....<b>"&SUM(B:B)&"</b>.... but obviously I take <b></b> in my cell and not the bold font weight.
How to style from formula in cell?
Recently I had the same problem, but I found a solution. This solution works well in google sheets.
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(E3,"A","๐"),"B","๐"),"C","๐"),"D","๐"),"E","๐"),"F","๐
"),"G","๐"),"H","๐"),"I","๐"),"J","๐"),"K","๐"),"L","๐"),"M","๐"),"N","๐"),"O","๐"),"P","๐"),"Q","๐"),"R","๐"),"S","๐"),"T","๐"),"U","๐"),"V","๐"),"W","๐"),"X","๐"),"Y","๐"),"Z","๐"),"0","๐"),"1","๐"),"2","๐"),"3","๐"),"4","๐"),"5","๐"),"6","๐"),"7","๐"),"8","๐"),"9","๐")
If you want to improve your formula, use the characters below:
ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz
๐๐๐๐๐๐
๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐ ๐ก๐ข๐ฃ๐ค๐ฅ๐ฆ๐ง๐จ๐ฉ๐ช๐ซ๐ฌ๐ญ๐ฎ๐ฏ๐ฐ๐ฑ๐ฒ๐ณ
At the current time, in Google Sheets you cannot bold partial components of any formula. The solution mentioned using the 'B' or bold icon only works if the desired bold selection is an entire cell containing a formula, or partial of a cell that does not contain a formula.
Yes, this is possible.
My own solution is at the bottom, but I find the one added by Adrian Mihai Nemes here to be cleaner. So, I have expanded that solution here to work for lowercase as well as uppercase and numbers. This should work for text containing anything, including newlines, single quotes, emojis, etc.
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B25,"A","๐"),"B","๐"),"C","๐"),"D","๐"),"E","๐"),"F","๐
"),"G","๐"),"H","๐"),"I","๐"),"J","๐"),"K","๐"),"L","๐"),"M","๐"),"N","๐"),"O","๐"),"P","๐"),"Q","๐"),"R","๐"),"S","๐"),"T","๐"),"U","๐"),"V","๐"),"W","๐"),"X","๐"),"Y","๐"),"Z","๐"),"a","๐"),"b","๐"),"c","๐"),"d","๐"),"e","๐"),"f","๐"),"g","๐ "),"h","๐ก"),"i","๐ข"),"j","๐ฃ"),"k","๐ค"),"l","๐ฅ"),"m","๐ฆ"),"n","๐ง"),"o","๐จ"),"p","๐ฉ"),"q","๐ช"),"r","๐ซ"),"s","๐ฌ"),"t","๐ญ"),"u","๐ฎ"),"v","๐ฏ"),"w","๐ฐ"),"x","๐ฑ"),"y","๐ฒ"),"z","๐ณ"),"0","๐"),"1","๐"),"2","๐"),"3","๐"),"4","๐"),"5","๐"),"6","๐"),"7","๐"),"8","๐"),"9","๐")
For my own solution, this will bold all lowercase, uppercase, and numbers. It should work for text containing just about anything, including newlines, single quotes, etc. (perhaps not emojis?).
Just replace the single A2 reference with whatever it is you want bolded:
=ARRAYFORMULA(JOIN("", UNICHAR(QUERY(UNICODE(SPLIT(TRANSPOSE(SPLIT(
REGEXREPLACE(
REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(A2&""
,"([^a-zA-Z0-9])","$1"&UNICHAR(160)&UNICHAR(1)&CHAR(127))
,"'","''")
,"([a-z])","$1"&UNICHAR(160)&UNICHAR(119738)&CHAR(127))
,"([A-Z])","$1"&UNICHAR(160)&UNICHAR(119744)&CHAR(127))
,"([0-9])","$1"&UNICHAR(160)&UNICHAR(120735)&CHAR(127))
,"'","''")
,CHAR(127))), UNICHAR(160))), "select Col1+Col2-1 label Col1+Col2-1 ''",0))))
Overview:
For each character group (lowercase, uppercase, numbers) we're using stringed together REGEXREPLACE calls to append special separator characters along with the base unicode character for that group's bold font right after.
So for example, Hi-1 becomes "H"&UNICHAR(160)&UNICHAR(119743)&CHAR(127)&"i"&UNICHAR(160)&UNICHAR(119737)&CHAR(127)&"-"&UNICHAR(160)&UNICHAR(1)&CHAR(127)&"1"&UNICHAR(160)&UNICHAR(120734)&CHAR(127).
Once we have this new string, we split on the `CHAR(127) and transform, so each of these characters are on their own row. So the example now becomes:
"H"&UNICHAR(160)&UNICHAR(119743)
"i"&UNICHAR(160)&UNICHAR(119737)
"-"&UNICHAR(160)&UNICHAR(1)
"1"&UNICHAR(160)&UNICHAR(120734)
Next, we split on the UNICHAR(160) character:
"H", UNICHAR(119743)
"i", UNICHAR(119737)
"-", UNICHAR(1)
"1", UNICHAR(120734)
We use the UNICODE() function to convert the actual characters along with their corresponding UNICHAR into their unicode numbers:
72, 119744
105, 119738
45, 1
49, 120735
Now, we use the QUERY() function as a way of summing each of these rows individually. That's where the "select Col1+Col2-1 label Col1+Col2-1 ''" comes in. It is adding column 1 to column 2 and taking away the 1 extra from the base unicode value, and then preventing a heading label from being added to the function output.
So, now we get:
119815
119842
45
120783
We use the next UNICHAR() function to convert these to their unicode characters, which at this point is the corresponding bolded character:
๐
๐ข
-
๐
Lastly, we use a JOIN() with an empty string "" delimiter to combine it all back into a single string.
๐๐ข-๐
p.s. If you're curious why the different character groups need to be split up, it's because each group lines up with their corresponding bold characters in order, but not all 3 character groups in a row. There are some extra characters between the normal type groups that you don't see in the bold section of unicode. Thus, each character group has to be given its own base unicode value to be added to that normal character's unicode value.
p.p.s. If you wanted to add more characters, you would just need to add another wrapping REGEXREPLACE() with the correct character group, and the UNICHAR() with the correct base unicode value for that group, and then add that new group to the exclusions from the first REGEXREPLACE(). Happy to explain this further if required.
p.p.p.s. The REGEXREPLACE() with the single quote ' being replaced with two single quotes '' is needed because when we split the characters to their own cells, Google Sheets actually considers a leading single quote as a special character and removes it. So effectively, two single quotes get converted to one single quote after splitting.
I updated Adrian's formula to style to sans-serif characters instead of serif ones if anyone needs it. It includes both lower and upper case letters, as well as numbers.
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(D2,"A","๐"),"B","๐"),"C","๐"),"D","๐"),"E","๐"),"F","๐"),"G","๐"),"H","๐"),"I","๐"),"J","๐"),"K","๐"),"L","๐"),"M","๐ "),"N","๐ก"),"O","๐ข"),"P","๐ฃ"),"Q","๐ค"),"R","๐ฅ"),"S","๐ฆ"),"T","๐ง"),"U","๐จ"),"V","๐ฉ"),"W","๐ช"),"X","๐ซ"),"Y","๐ฌ"),"Z","๐ญ"),"a","๐ฎ"),"b","๐ฏ"),"c","๐ฐ"),"d","๐ฑ"),"e","๐ฒ"),"f","๐ณ"),"g","๐ด"),"h","๐ต"),"i","๐ถ"),"j","๐ท"),"k","๐ธ"),"l","๐น"),"m","๐บ"),"n","๐ป"),"o","๐ผ"),"p","๐ฝ"),"q","๐พ"),"r","๐ฟ"),"s","๐"),"t","๐"),"u","๐"),"v","๐"),"w","๐"),"x","๐
"),"y","๐"),"z","๐"),"0","๐ฌ"),"1","๐ญ"),"2","๐ฎ"),"3","๐ฏ"),"4","๐ฐ"),"5","๐ฑ"),"6","๐ฒ"),"7","๐ณ"),"8","๐ด"),"9","๐ต")
EDIT
I understood how to use the "Substitute" formula but I have a question: is it possible to use another font? (Montserrat). The substitute formula seem to force a specific font regardless of the font I am selecting for that cell.
Here is what I also tried:
I noticed that when I CCed the substitute formula in an empty cell in a google sheet, every letter/number is followed by its bold version.
I thought it was just a matter of the font being used within the formula so I CCed the formula in a google doc and manually changed the font as well as every bold letter and number to Montserrat. They appear "correctly" within google doc, however when I CC that modified substitute formula in an empty cell in google sheet, it doesn't keep the bold letters and numbers. How come CCing from here keeps the bold letters/numbers in google sheet, and CCing from a google doc have the bold letters/numbers reset to regular version?
Please help me figure this out
Yours,
--Jay
Having the same issue at the moment. Spent a decent amount of time figuring it out before I realized it cannot be done. The reason for this is that Google spreadsheets does not allow bits of a query to have bold/italics/underline to it.
The only workaround I have found is to do it manually . Let the query run , and highlight the section of the string you want with a different formatting option.
To make any of the cells bold just make a conditional format for the cell/range/array and choose bold.