cant remove whitespaces from hexadecimal string EXCEL - excel

I have an excel file with one column with hexadecimal values in this format: 00 00 00 and I want to change them into decimal values so I tried using REPLACE to remove white spaces:
=REPLACE(A1," ", , "")
but what I got was #VALUE!
Why is that?

If you want to convert from hexadecimal to decimal, merely removing white space from a certain format won't do that. Use the function HEX2DEC() instead. To apply it, you do need to remove the spaces:
=HEX2DEC(SUBSTITUTE(A1, " ",""))

I used =HEX2DEC(SUBSTITUTE(A1," ","")) and that worked, so I guess SUBSTITUTE works better here than REPLACE

Related

Keeping leading zeros with find and replace

I'm using Excels find and replace to remove hyphens from long numbers. They are mixed between birth dates and organisation numbers that have been filled with leading zeros to have the same number of characters. There are a LOT of numbers so find and replace seems to be the simplest solution to remove the hyphens.
But when i use find and replace the leading zeros are truncated and I have not found a solution to keep them afterwards.
For example i have:
19551230-1234
01234567-8901
and after find and replace I have
1,95512E+11
12345678901
but want the format as:
195512301234
012345678901
So I want to keep the leading zeros after find and replace. I've tried formatting the cells as text, but it doesn't work as the find and replace automatically truncates the leading zero and keeps the remaining characters, so the zero is completely removed. I am using Excel 2010, but answers for several versions are appreciated.
Just put a single quote in front of your leading number - ex. '01234 It will take the number as-is literally and the quote will not show in the field.
Use the SUBSTITUTE formula instead of Find and Replace like so:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1," ",""),"/",""),")",""),"(",""),"-","")
The result is text.

How in Excel to Remove only 1st comma (exact character, symbol or string)

I have numbers witch when is 1000 then has comma "," before hundreds like 1,234,00
How to remove 1st comma or make 2nd to appear so it would be 1234,00 or in excel as it works as number if has only space then with space or comma?
I have formula so far for getting number
=MID(LEFT($A604;FIND(" on ";$A604)-1);FIND("?";$A604)+1;LEN($A604))*1
And for removing all i put it in substitute to remove commas but that makes number wrong higher like 123400
=SUBSTITUTE(MID(LEFT($A604;FIND(" on ";$A604)-1);FIND("?";$A604)+1;LEN($A604));",";"")*1
The issue is the format #,##0, puts a comma before every third number. You need to treat it as a string
Try this in B2:
=IF(A2<999,A2,CONCATENATE(MID(A2,1,LEN(A2)-3),",",MID(A2,LEN(A2)-2,3)))
Depending on your use it might be best to remove the IF

Trim not removing white spaces?

I have a field with hex a decimal values that look like FF FE, I need to remove the white space so the results are FFFE but trim is not working for me! Is there another function I can use?
Trim only removes whitespace at the beginning and end. Use substitute instead.
=SUBSTITUTE({cell ref}," ","")
should do the trick

How to remove trailing spaces from text

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

Add leading zeroes/0's to existing Excel values to certain length

There are many, many questions and quality answers on SO regarding how to prevent leading zeroes from getting stripped when importing to or exporting from Excel. However, I already have a spreadsheet that has values in it that were truncated as numbers when, in fact, they should have been handled as strings. I need to clean up the data and add the leading zeros back in.
There is a field that should be four characters with lead zeros padding out the string to four characters. However:
"23" should be "0023",
"245" should be "0245", and
"3829" should remain "3829"
Question: Is there an Excel formula to pad these 0's back onto these values so that they are all four characters?
Note: this is similar to the age old Zip Code problem where New England-area zip codes get their leading zero dropped and you have to add them back in.
=TEXT(A1,"0000")
However the TEXT function is able to do other fancy stuff like date formating, aswell.
The more efficient (less obtrusive) way of doing this is through custom formatting.
Highlight the column/array you want to style.
Click ctrl + 1 or Format -> Format Cells.
In the Number tab, choose Custom.
Set the Custom formatting to 000#. (zero zero zero #)
Note that this does not actually change the value of the cell. It only displays the leading zeroes in the worksheet.
I hit this page trying to pad hexadecimal values when I realized that DEC2HEX() provides that very feature for free.
You just need to add a second parameter. For example, tying to turn 12 into 0C
DEC2HEX(12,2) => 0C
DEC2HEX(12,4) => 000C
... and so on
I know this was answered a while ago but just chiming with a simple solution here that I am surprised wasn't mentioned.
=RIGHT("0000" & A1, 4)
Whenever I need to pad I use something like the above. Personally I find it the simplest solution and easier to read.
I am not sure if this is new in Excel 2013, but if you right-click on the column and say "Special" there is actually a pre-defined option for ZIP Code and ZIP Code + 4. Magic.
If you use custom formatting and need to concatenate those values elsewhere, you can copy them and Paste Special --> Values elsewhere in the sheet (or on a different sheet), then concatenate those values.
Even this will work nicely
REPT(0,2-LEN(F2)&F2
where 2 is total number of digits, for 0 ~ 9 -> it will display 00 to 09 rest nothing will be added.
Assuming that the number you want to pad is in cell A1, and the "padding number of zeros" is 4 ,
e.g.
"23" should be "0023",
"245" should be "0245", and
"3829" should remain "3829"
then
=TEXT(A1,REPT("0",4))

Resources