left("123-456-7890",3)

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
A1=left("123-456-7890",3)

The result A1 = 123 (but as a text, aligned to the left side of the cell). I changed the format to number, general etc it is still text.

I learnt if B1=1 and I copy B1 and Paste Special (multiple) A1 then A1 will be 123 as a number (aligned to the right).

I also tried before doing the paste special to do this C1=A1-1 (the result was 122) correct!!

My question, if the result of left() is a text but excel still can understand it as a number, then why I need to change the format? or what the issue I might have in the future if i kept the result of left() as it is?

Thanks you.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
It will depend what functions you use it with. Most number functions, as opposed to operators like +, will ignore text. If you want a true number, use:

=left("123-456-7890",3)+0
 
Upvote 0
If you want to coerce a number with your formula try:
Code:
=LEFT("123-456-7890",3)+0
 
Upvote 0
Thank you all for your reply and help. adding 0 is good idea. But now I have a question

the result of A1=left ("123-456-7890",3) is 123 (as a text)

but when I do B1=A1-1, I got B1=122 (so what is the problem? that is my question why I should bother to change the text to number format when excel will understand 123 as a number anyway? Thank you.
 
Upvote 0
If you do something like a vlookup then the number 123 does not = 123 as text.


Excel 2010
ABC
3123-151231
41562
5
6
7123#N/A123 is number vlookup does not find 123 as text
81231123 as text finds 123 as text
Sheet3
Cell Formulas
RangeFormula
B3=LEFT(A3,3)
B7=VLOOKUP(A7,B3:C4,2)
B8=VLOOKUP(A8,B3:C4,2)
 
Upvote 0
Thank you all for your reply and help. adding 0 is good idea. But now I have a question

the result of A1=left ("123-456-7890",3) is 123 (as a text)

but when I do B1=A1-1, I got B1=122 (so what is the problem? that is my question why I should bother to change the text to number format when excel will understand 123 as a number anyway?
Excel is always trying to help (sometime detrimentally as with values that look like dates but are not meant to be dates). In the case of text values that "look" like numbers, Excel will convert such a text value to a real number in order to perform the indicated math operation. That is why adding 0 to the LEFT function makes the text value returned by the LEFT function a real number. A1-1 is does the same thing except is math operation is to decrement the "number" in cell A1 (adding 0 to the LEFT function does not increase or decrease the value returned from the LEFT function).
 
Upvote 0
If you have say three cells like that, =A1+A2+A3 will return a correct total, but =SUM(A1:A3) will return 0.
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,443
Members
448,898
Latest member
drewmorgan128

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top