cell data entry formatting

theYaniac

Board Regular
Joined
Jan 7, 2018
Messages
64
Office Version
  1. 365
Platform
  1. Windows
I am trying to format the cells in which I enter data. I receive invoice numbers from our department head, the invoice numbers vary in length. I need all entries to be 11 digits in length. If the invoice number I receive is only six digits in length, I need the first five to be zeros. Example, I receive the invoice numbered (123456) I need it to display as (00000123456) when I enter it into the system. Same for an eight digit invoice (12345678) needs to be (00012345678) when entered. Could someone suggest a way to format the cells where I am doing the data entry to display as needed? Thank you in advance.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi,

If you just want to display it this way, it can be done very easily using Excel number formats.
just create a new personalized format with 11 "0" :

0000000000

Hope it helps.
 
Upvote 0
Hi.
a basic macro can do it.

Function addZero(cell As Range)
c = cell.Cells(1, 1)
While (Len(c) < 11)
c = "0" & c
Wend
addZero = c
End Function


Just add this into a module in VBA.
Then use it as a formula in excel cell like this :
=addZero(A1)
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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