Leading zero's in cells

dwrowe001

Board Regular
Joined
Mar 12, 2017
Messages
53
Office Version
  1. 2016
Platform
  1. Windows
Hi,
I am having the hardest time trying to get leading zeros to appear in cells...
I'm trying to append of concatenate digits from one cell with digits from another cell:

[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD]E
[/TD]
[TD]F
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]03
[/TD]
[TD]15
[/TD]
[TD]17
[/TD]
[TD]20
[/TD]
[TD]32
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I want for example to get "03" in A1 and the "1" in B1 to combine in cell A2.
I have tried following formulas in A2:
=A1&LEFT(B1,1)... which results in 31 appearing in A2.
=LEFT(A1,2)&LEFT(B1,1)... which results in 31 appearing in A2.
strange thing is, if I just put =A1 in A2, then "03" appears in A2. I've changed cell formatting in A2 to custom and "000". How do I combine the "03" in A1 and the first digit in B1 to go into A2?...
Not sure if it's important or not, I'm using Excel 2016.
Doesn't seem right that doing this is so hard? Am I way wrong with the formulas I've tried?
Dave
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Re: Leading zero's in cells -- HELP!!

You could try this with combined with the 000 custom format:

=(A1&LEFT(B1,1))*1
 
Upvote 0
Re: Leading zero's in cells -- HELP!!

You could try this with combined with the 000 custom format:

=(A1&LEFT(B1,1))*1

Yes, that works... but what if in B1 instead of 15 you have 03? It worked when the first digit in B1 is anything but 0..
 
Upvote 0
Re: Leading zero's in cells -- HELP!!

From what you describe, I think A1 actually only contains the number 3 but is Custom formatted as "00". I think B1 is similarly Custom formatted as "00".
Try this formula

=TEXT(A1,"00")&LEFT(TEXT(B1,"00"),1)
 
Upvote 0
Re: Leading zero's in cells -- HELP!!

What does the *1 do??

Since LEFT is a string function, it returns a text string. The *1 converts the number stored as text to a real number so it works with the custom format. I did not test extensively, so give Peter's formula a go.
 
Upvote 0
Re: Leading zero's in cells -- HELP!!

Excellent, thank you both for your help... They both work depending on positions of my numbers.. thanks so much!!
 
Upvote 0
Re: Leading zero's in cells -- HELP!!

You are very welcome.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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