Formatting a 19 Digit Budget Code

G

Guest

Can anyone help me format a 19 digit budget code? The format needs to be XXXX-XXXX-XX-XXX-XXXXXX. An example of a budget code that I need formatting would be: 1110-2100-38-068-61121

Thank

Wayne
 
G

Guest

Hi Again Wayne
I put together the following VBA code which you might find useful. If you copy this into a VB module you can assign it to a button or command key. Then after you enter your number into a text formatted cell you can run the macro to rewrite the text with the hyphens

Good Luck
Mark Graesse
(e-mail address removed)
Boston M

Sub Macro1(
onum = ActiveCell.Formul
ActiveCell.Formula = Left(onum, 4) & "-" &
Mid(onum, 5, 4) & "-" &
Mid(onum, 9, 2) & "-" &
Mid(onum, 11, 3) & "-" &
Right(onum, 6
End Su

----- Mark Graesser wrote: ----

Wayne
You won't be able to do this with a number format. Excel limits numbers to 15 significant figures. Any digits beyond 15 will change to zeros

In order to maintain your full number you will have to format the cells as text. Then you cannot use number formatting to insert the hyphens

You could enter the number, as text, in a seperate cell and then use a series of LEFT, MID, RIGHT and & to get the format you want in a seperate cell. You might also be able to use an event macro to change the number after you enter it

Good Luck
Mark Graesse
(e-mail address removed)
Boston M

----- Wayne wrote: ----

Can anyone help me format a 19 digit budget code? The format needs to be XXXX-XXXX-XX-XXX-XXXXXX. An example of a budget code that I need formatting would be: 1110-2100-38-068-61121

Thank

Wayne
 
D

Dave Peterson

See a bunch of responses to your other thread.
Can anyone help me format a 19 digit budget code? The format needs to be XXXX-XXXX-XX-XXX-XXXXXX. An example of a budget code that I need formatting would be: 1110-2100-38-068-611211

Thanks

Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top