Concatenate without losing leading zeroes?

paquirl

Board Regular
Joined
Oct 12, 2010
Messages
190
Office Version
  1. 2016
Platform
  1. Windows
Column A has numbers that should all be 6 digits. Some have leading zero(es).
Column B has numbers that should all be 5 digits. Some have leading zero(es).
Column C should combine both A and B with every cell having an 11 digit number.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,159
Office Version
  1. 365
Platform
  1. Windows
Try:
VBA Code:
=TEXT(A1,"000000") & TEXT(B1,"00000")
for an entry in row 1.
 
Solution

paquirl

Board Regular
Joined
Oct 12, 2010
Messages
190
Office Version
  1. 2016
Platform
  1. Windows
I used as a formula in C1 and it is giving me an invalid name error. Says the formula contains unrecognizable text.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,159
Office Version
  1. 365
Platform
  1. Windows
I used as a formula in C1 and it is giving me an invalid name error. Says the formula contains unrecognizable text.
The TEXT function has been around forever in Excel, so that should not cause any issues.

Which version of Excel are you using? If a European version, you may need to use semi-colons instead of commas, i.e.
Excel Formula:
=TEXT(A1;"000000") & TEXT(B1;"00000")

You aren't doing this in Google Sheets, by chance, are you?
 

paquirl

Board Regular
Joined
Oct 12, 2010
Messages
190
Office Version
  1. 2016
Platform
  1. Windows

ADVERTISEMENT

Using 2016, standard US version , no Google sheets.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,159
Office Version
  1. 365
Platform
  1. Windows
Using 2016, standard US version , no Google sheets.
There is nothing in that formula that should cause any issues.
Did you copy and paste it in directly, or did your try to re-type it yourself?

What exactly is in cells A1 and B1 (please post examples)?
Are they hard-coded, or are they the result of formulas?
If formulas, please post those formulas.
 

paquirl

Board Regular
Joined
Oct 12, 2010
Messages
190
Office Version
  1. 2016
Platform
  1. Windows

ADVERTISEMENT

ok i see something odd, this particular spreadsheet (sent to me by a colleague) has numbers for column headers instead of the letters.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
66,064
Office Version
  1. 365
Platform
  1. Windows
Sounds like it's using R1C1 notation, in which case try
Excel Formula:
=TEXT(RC[-2],"000000") & TEXT(RC[-1],"00000")
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,159
Office Version
  1. 365
Platform
  1. Windows
ok i see something odd, this particular spreadsheet (sent to me by a colleague) has numbers for column headers instead of the letters.
Ah yes.
The devil is often in the important details left out!
 

paquirl

Board Regular
Joined
Oct 12, 2010
Messages
190
Office Version
  1. 2016
Platform
  1. Windows
it wont let me select both formulas as the solution to this thread :(
 

Forum statistics

Threads
1,148,393
Messages
5,746,437
Members
424,018
Latest member
dionlkk6

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
Top