# Add 0 to a bunch of columns

I have an Excel spreadsheet I need to add 0 in front of numbers currently in over 2000 cells
Any suggestions are appreciated.

Thanks
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Just put this formula to the adjacent cell

Assuming your data is in column a starts with second row then put the below formula in B2 and then copy down

="0"&A2
0
Commented:
Are the columns formatted as text?
The simplest way would be to use an adjacent (or new) column with a formula that prepends the "0" characte
Example:
``````="0"&A1
``````
Copy/paste special (Values)  the new/formula column and then delete the original column
0
Commented:
Is this for display purposes? If not, a number starting with a zero will need to be entered as text.

To display a zero in front, you can sue Number Formatting, with this format - "0"#
0
Commented:
or if you want to change all of the cells at once, then run the below code from a module

``````Sub test()

Dim MyRange As Range
Set MyRange = ActiveSheet.UsedRange
Dim c
For Each c In MyRange
If IsNumeric(c.Value) Then
c.NumberFormat = "@"
c.Value = 0 & c.Value
End If
Next c

End Sub

``````
0
Group Finance ManagerCommented:
You can use a Custom Number Format

Select the cells
Right click and choose Format cells
Then click Custom
In the Type box enter 0000

You can adjust the number of zeros to suit your requirements. This means that the numbers will still be numbers and can be used in calculations but will display leading zeros.
0
Commented:
If the number of zeroes you need to add is variable, and the total length of the field is a fixed number, you may need this formula

=REPT(0,5-LEN(B3))&B3

In this case, the total length of the field is five characters.  See attached workbook example
EE.xlsx
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Citrix Systems / Network AdminAuthor Commented:
This is a spreadsheet which has all of our Inventory we are currently migrating from Retail Support Services RSS to QuickBooks.  Need to append 0 to make all numbers contain 8 charters.
0
Commented:
Sub test()

Dim MyRange As Range
Set MyRange = ActiveSheet.UsedRange
Dim c
For Each c In MyRange
If IsNumeric(c.Value) Then
c.NumberFormat = "00000000"
c.Value = 0 & c.Value
End If
Next c

End Sub
0
Commented:
Did you look at my comment?
0
Commented:
0
Citrix Systems / Network AdminAuthor Commented:
Thanks for the help with this,
Roy Cox when i do what you suggested Format is greyed out

tomfarrar I have not tried what you suggested I will attempt this over the next couple of days & post back.
0
Group Finance ManagerCommented:
Is the sheet protected?
0
Commented:
Please let me know.   I have used this formula many times to add zeroes to the front of fields where the existing data  has variable lengths.   - Tom
0
Older than dirtCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
Commented:
I believe that what the OP has asked was provided to him my answer 4096971 answers the exact question
0
Commented:
4096971 is not a comment in this thread
0
Commented:
thanks aikimark for pointing the mistake, I actually meant the comment Id 40969741
0
Commented:
My two comments should work also:

=REPT(0,5-LEN(B3))&B3