Adding zero's to the end of a text string

sandy6078

New Member
Joined
Jul 19, 2007
Messages
2
I have a column of vendor id numbers that are text. The id is supposed to be six characters long. I need to add zero's to the end of the text strings that are not six characters long.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Let's say your ID numbers are in col A.
Code:
=left(A1&"000000",6)
and copy down as required.
If any of your ID numbers are already more than 6 characters long, this formula will cut them down to the first 6, but there are ways round that if you need it.
 
Upvote 0
Will that work with codes that already 6 digits long, as they will now be 7 digits ?

If they are always 5 or 6 digits long then would this work ?

Code:
=IF(LEN(B4)=6,B4,IF(LEN(B4)=5,B4&"0"))
 
Upvote 0
Thorin - are you referring to 98illini's solution ? (now deleted).

I think my solution will work for any length of ID code from zero characters to six and more.
 
Upvote 0
The id's are in col A and there are id's that are ids that are the correct length.
This will hopefully be part of a code to clean up a spreadsheet prior to being imported from Access (or exported to Access).
 
Upvote 0

Forum statistics

Threads
1,214,792
Messages
6,121,612
Members
449,039
Latest member
Mbone Mathonsi

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