Add zero to existing numbers

Steelband

New Member
Joined
Dec 18, 2021
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Cell C146 formatted general contains numbers 81621 and continues to cell c500. Need to add number 0 for cell to read 081621
(Cell C147 reads 81721 and needs to read 081821)
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Cell C146 = 81621
If you need to have 081621 in Cell D146 insert the following formula:
Excel Formula:
=TEXT(C146,"000000")
 
Upvote 0
You can select the range C146:C500 and Format Cells as: 000000
 
Upvote 0
Welcome to the MrExcel board!

Yet another possible interpretation of what you might want is this.
Test with a copy of your workbook.

VBA Code:
Sub AddZero()
  With Range("C146:C500")
    .NumberFormat = "@"
    .Value = Evaluate(Replace("if(#="""","""",0&#)", "#", .Address))
  End With
End Sub
 
Upvote 0
If you only want the cell to display a single zero in front of the number (the value in the cell does not physically change, only its appearance), then you can use this Custom Format to do it...

\0#

Peter has given you a macro to use if this is not what you wanted.
 
Upvote 0
Solution
If you only want the cell to display a single zero in front of the number (the value in the cell does not physically change, only its appearance), then you can use this Custom Format to do it...

\0#

Peter has given you a macro to use if this is not what you wanted.
Thank you Rick. Reason I don't add the zero's is that there are more than 100 lines involved. I went to concatenate instead. Thanks to Peter, Phuoc and Barmaster for the input.
 
Upvote 0

Forum statistics

Threads
1,202,987
Messages
6,052,939
Members
444,617
Latest member
Rush1984

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