How to remove trailing spaces from text - string

In a Google spreadsheet I have some data imported from a .csv file which is loc A1 = 123.4 followed by 2 spaces
I want to use the numeric value but the spreadsheet refuses to recognize the string as a number.
The obvious answer is substitute(A1;" ";"") but this does not work!!. Nor do any of the other string search commands.
Am I going insane?
I am using a Mac running 10.4.7 and chrome

Not sure if you have already solved this... try this...this seems to be working
=Value(Substitute(A13,CHAR(160), ""))
or
=Substitute(A13,CHAR(160), "")*1

OK. I've examined this in Excel (where I'm more handy with VBA/etc) and these are not ordinary "spaces" in your cell, they are actually non-breaking spaces, an ascii chr value of 160 (ordinary space is Chr(32)).
Try this formula to replace the non-breaking space character with a null string:
=SUBSTITUTE(A13,CHAR(160),"")
Excel has a function called Clean() which removes non-printing characters like this, but I do not see this function in Google Docs.

Thanks #kaushai and #davidzemens
I have edited line 22 of the sheet.
It shows that =Substitute(A4,CHAR(160), "") is not numeric
however =Substitute(A4,CHAR(160), "")*1 is numeric
and =value(Substitute(A4,CHAR(160), "")) is numeric

Related

extract text from between two words

I'm trying to extract text between two specific words in Excel. First word is unique, but problem is that second word (it's actually a character) is not unique and can be even before "first word" in text, and that's where I have problem.
So, I need any text starting with first word "dimenzija" and anything up to first time we get to character ";", and I menage to set formula for that, but problem is if character ";" shows up in text before text "dimenzija"
Text example where my formula doesn't work:
Some text ; and text dimenzija: 10x10; some other text.
So here, I should get this: "dimenzija: 10x10" but I get Error #VALUE! code instead.
Code I'm using:
=MID(I2;SEARCH("dimenzija";I2);SEARCH(";";I2)-SEARCH("dimenzija";I2))
*So text is in I2 cell
Also, I have one other problem, if that block of text is at the end of the line, then it has no ";" at the end, but I'd still like to extract it, is it possible to do it without adding ";" on the end of the text?
Example:
Text; some text; dimenzija: 10x10
so in this example, I would like for my code to extract text "dimenzija: 10x10" as well if possible.
Try below formula-
=LEFT(MID(A1,SEARCH("dimenzija",A1),LEN(A1)),SEARCH(";",MID(A1,SEARCH("dimenzija",A1),LEN(A1))))
Looks like you can use:
=MID(A1,FIND("dimenzija",A1),FIND(";",A1&";",FIND("dimenzija",A1))-FIND("dimenzija",A1))

How to replace wildcharacter in CSV

I have below string in csv files
Part Number WP1166496 (AP6005317) replaces 1166496, 1156976.
Expected Output -
Part Number WP1166496 replaces 1166496, 1156976.
I want to replace (AP6005317) this with blanks.
As there are many rows with different values.
So how can I replace this string with brackets to blanks value.
I don't know how to achieve this exactly in Microsoft Excel.
If you look for find and replace feature, most probably you can see option to replace with regular expressions.
Use regular expression option and replace \(.*\) with (simple space). This will solve your problem.
Note : This is tested and verified in LibreOffice Calc.

remove a character from the end of a text string only if it is there in excel

I have a list of file names in excel I need to Match with another list. Some of the file names contain extra characters that need to be removed first though. I have a formula that will remove special characters and spaces from the file names;
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($E8,"_",""),"-",""),".","")," ","")
But some of the file names contain an extra 1 at the end I need to remove, please see example;
2AALNOR120114
DCA CDE 12-01-14
OPASDOCS120114
TWASCE1202141
TWASCE1203141
STCSRA120120141
STCSRA120220141
If anyone could give me a Formula solution that strips out the above special characters and the 1 at the end of the filename that would be great.
Bonus credit if you can also strip out the 20 from the STC files as well to output as STCSRA120114 instead of STCSRA12012014
Edit: For clarification, final result would ideally look like this;
2AALNOR120114
DCACDE120114
OPASDOCS120114
TWASCE120214
TWASCE120314
STCSRA120114
STCSRA120214
Thanks,
Ben
Maybe:
=LEFT(A1,LEN(A1)-IF(RIGHT(A1,1)="1",1,0))
(Replace the first two instances of A1 above with a suitable version of your SUBSTITUTE formula, and the last with E8).
With substitution:
=LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(E8,"_",""),"-",""),".","")," ",""),LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(E8,"_",""),"-",""),".","")," ",""))-IF(RIGHT(E8,1)="1",1,0))
A sightly shorter version of the A1 one:
=LEFT(A1,LEN(A1)-(RIGHT(A1)="1"))

Remove everything after certain string in Excel 2007

A B
1 www.harborfreight.com/ www.harborfreight.com
2 totsy.com totsy.com
3 www.totsy.com/customer/account/login/ www.totsy.com/customer/account/login
4 www.pandawill.com/ www.pandawill.com
I am trying to reduce the above Column A values to their simplest domain name form by removing every character after the first "/". It doesn't work on line 3 above using this formula:
=IF(ISERROR(SEARCH("/",A3)),A3,TRIM(LEFT(A3,FIND("|",SUBSTITUTE(A3,"/","|",LEN(A3)-LEN(SUBSTITUTE(A3,"/",""))))-1)))
Obviously my formula above seems to be stripping every character after the last "/". Can you please recommend the correct change?
Thanks,
Dan
Your formula seems very convoluted to me, is there a reason you are messing with substitutions?
This seemingly works fine for me:
=IFERROR(LEFT(A1,FIND("/",A1)-1),A1)
In that it returns the string before the first /, or just returns the string if / is not found.
Use this formula.
=MID(A1;1;if(ISERR(find("/";A1))=true;"99";find("/";A1)-1))
It finds the "/" character and returns text before it. Errorproof.

How do I get the last character of a string using an Excel function?

How do I get the last character of a string using an Excel function?
No need to apologize for asking a question! Try using the RIGHT function. It returns the last n characters of a string.
=RIGHT(A1, 1)
=RIGHT(A1)
is quite sufficient (where the string is contained in A1).
Similar in nature to LEFT, Excel's RIGHT function extracts a substring from a string starting from the right-most character:
SYNTAX
RIGHT( text, [number_of_characters] )
Parameters or Arguments
text
The string that you wish to extract from.
number_of_characters
Optional. It indicates the number of characters that you wish to extract starting from the right-most character. If this parameter is omitted, only 1 character is returned.
Applies To
Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000
Since number_of_characters is optional and defaults to 1 it is not required in this case.
However, there have been many issues with trailing spaces and if this is a risk for the last visible character (in general):
=RIGHT(TRIM(A1))
might be preferred.
Looks like the answer above was a little incomplete try the following:-
=RIGHT(A2,(LEN(A2)-(LEN(A2)-1)))
Obviously, this is for cell A2...
What this does is uses a combination of Right and Len - Len is the length of a string and in this case, we want to remove all but one from that... clearly, if you wanted the last two characters you'd change the -1 to -2 etc etc etc.
After the length has been determined and the portion of that which is required - then the Right command will display the information you need.
This works well combined with an IF statement - I use this to find out if the last character of a string of text is a specific character and remove it if it is. See, the example below for stripping out commas from the end of a text string...
=IF(RIGHT(A2,(LEN(A2)-(LEN(A2)-1)))=",",LEFT(A2,(LEN(A2)-1)),A2)
Just another way to do this:
=MID(A1, LEN(A1), 1)

Resources