I have a column of phone numbers
e.g
344-444022-22
234325343
(545)3454-3454
These are some formats
I want to convert all the phone numbers to simple 345354 format no dashes or brackets and also i ant to add USA Code "1" in front of all numbers
How can i do that in excel?
Assuming A1 is the reference where the phone number is you could use the following formula in a cell to remove the characters '(' '-' and ')'
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"(",""),")",""),"-","")
Copying this formula for all of the phone numbers should work if these are the only characters that are used in the different formats.
EDIT
If there is another character that you would like to remove, lets assume ' ', you can simply surround this formula with another SUBSTITUTE function, which works like the following:
SUBSTITUTE(source_text,text_to_replace,replace_with_this)
Making the formula:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"(",""),")",""),"-","")," ","")
You could use a formula:
=1&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"-",""),")",""),"(","")
There is probably a more concise way to do this. But his should work.
Related
I have in a cell two numbers "=5+4" as a text. This is a result of another operation.
I took a part of another formula and concatenated it with "equal" symbol:
= "=" & RIGHT(FORMULATEXT(V8);LEN(FORMULATEXT(V8))-SEARCH("+"; FORMULATEXT(V8)))
I want to get the result of 5+4 in a cell- which means "9" ;)
I DO NOT WANT TO USE VBA code.
my initial problem was to extract all numbers except the first one from an equation and sum in another cell: A1: "=6+5+4". A2: "9". Maybe it can be solved without VBA?
You could try (assuming only addition):
Formula in B1:
=SUM(FILTERXML("<t><s>"&SUBSTITUTE(MID(A1,2,LEN(A1)),"+","</s><s>")&"</s></t>","//s[position()>1]"))
In fact, if you don't want to use the 1st number we could also discard taking '=' into account:
=SUM(FILTERXML("<t><s>"&SUBSTITUTE(A1,"+","</s><s>")&"</s></t>","//s[position()>1]"))
And since SUM() will ignore text in the final answer, we can now even further simplify this (thanks #JosWoolley):
=SUM(FILTERXML("<t><s>"&SUBSTITUTE(A1,"+","</s><s>")&"</s></t>","//s"))
If you are always adding 2 numbers, then you can use this:
=VALUE(VALUE(MID(A1;2;SEARCH("+";A1)-2))+VALUE(MID(A1;SEARCH("+";A1)+1;9999)))
My column A is formatted as text, and all values follow same pattern: =Value1+Value2
So the formula extracts Value1 and Value2 as text with MID functions, based on the position of + symbol. Then Excel convert both values into numeric with VALUE function. Notice there are 3 values, the third one is to make sure the cell stays at standar format (in some versions of Excel, like mine 2007, when involving text formatted cells into formulas, the formulated cell autoformat itself to text format, making the formula to work just once).
As you can see in the image, it works perfectly but this is just for pattern =Value1+Value2. For different patters you'll need different formulas.
If you want to make a formula to work with all patterns, then indeed you need VBA.
I am using the formula:
=(INDEX($A$2:$A$300, MATCH(0, COUNTIF($B$1:B1, $A$2:$A$300), 0))
This takes a list of values from column A and reproduces it in column B to show each value only once, i.e. if a value is duplicated, it gets skipped.
For the most part it is working exactly as I hoped, however, some of the values in column A contain the wildcard character '?'.
Is it possible to get this formula to treat the '?' as just a standard character? Ideally I would like to include this rule in the formula itself rather than having to do a 'find and replace' with '~?'. Is this at all possible?
Many thanks
Change your formula to:
=(INDEX($A$2:$A$300,MATCH(0,COUNTIF($B$1:B1,SUBSTITUTE($A$2:$A$300,"?","~?")),0)))
confirmed with ctrl+shift+enter
This replaces the ? in the criteria array with ~? within your formula.
You need to "escape" those characters. This is done the same as when searching in Excel, by prepending them with the tilde character: ~
So this searches for the question mark:
=MATCH("~?",A1:A10,0)
I want to add some values in my excel sheet , but when there is no value want hyphen instead of zero .
Here is my formula as below :
=IFERROR(SUMIF(A1:A6,"="&VLOOKUP($F$3,A1:B6,1,FALSE),B1:B6),"-")
The formula for that'd be:
=IFERROR(IF(SUMIF(A1:A6,"="&VLOOKUP($F$3,A1:B6,1,FALSE),B1:B6)=0,"-",SUMIF(A1:A6,"="&VLOOKUP($F$3,A1:B6,1,FALSE),B1:B6)),"-")
But I suspect you just want to change the number format to ACCOUNTING... it automatically replaces zeros with hyphens.
I'm trying to format a column based off of another (let's say column B2). The column contains a value like "ABC011" and I need to bring in just the letters "ABC".
For another column I also need to bring in just the numbers "011" but without the trailing zeroes (although I imagine that if I can get the solution for the first question I'll be able to figure out the second).
Thanks in advance.
EDIT: The length of the characters can change but the numbers are USUALLY 2 or more digits as well as the letters.
To isolate the first characters from the numbers, in C2 this array formula:
=MID(B2,1,MIN(IF(ISNUMBER(SEARCH({0,1,2,3,4,5,6,7,8,9},B2)),SEARCH({0,1,2,3,4,5,6,7,8,9},B2)))-1)
Being an array formula it must be confirmed with Ctrl-Shift-Enter when leaving edit mode. If done correctly then Excel will put {} around the formula.
If you have excel 2010 or later you can use this non CSE Formula instead of the one above. It does not require the Ctrl-Shift-Enter:
=MID(B2,1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},B2),1)-1)
Then using that result in D2 we put:
=RIGHT(B2,LEN(B2)-LEN(C2))
This will put it in as a string, if yo want to make it a number just put -- in front:
=--RIGHT(B2,LEN(B2)-LEN(C2))
This will return the number as a number so 011 will become 11
To get the numbers
I have column in excel like below,
'04-Feb-01
'04-Mar-01
'08-Apr-01
'06-May-01
'03-Jun-01
'08-Jul-01
'05-Aug-01
I want to remove the character ' in all cells how can i do that?
I already tried with =RIGHT(A1,LEN(A1)-1) this one.. not working
Convert the text to a date using DATEVALUE. Then apply a date format to your liking.
When you enter data into a cell, Excel will try and convert it to the correct type (is it text, a number or a date) The single quote is Excel's way of saying treat what follows as text. It comes in handy when entering things like telephone numbers which Excel might think is a number and would not display leading zeros. In your the example the actual value in the cell is the text without the single quote, you can check this by copying a cell and then pasting into notepad and there would be no quote in the result.
Why do you want to remove the quote? If it is because you want the cells to contain a date rather than text you can convert it using the DATEVALUE function or by using copy and paste special values only .