Autofill if value short

matts

New Member
Joined
Sep 11, 2002
Messages
41
Please Help.

I want to build a script to autofill a cell if the value entered is short. i.e all cells should be in the format A9999999. This is fine if the number is B1234567 however if the number is B0000123 then often our people may only enter B123 as it may be all that someone wrote on the item. I do not wish to put a validation on the cells which forces the person to enter the predefined format or number of characters. I would prefer they just entered what they saw. I would like a script that acted on a change to any value in column A from Row 9 down and put the zero's in after the alpha if applicable.

Any idea's would be appreciated.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Can anybody help?

if any cells in Column A from row 9 down are B123, I want to zero fill after the alpha to make up a set number of characters ie 8.

Matt
 
Upvote 0
I don't write much VBA code, but if you're interested here's the Excel formula approach...

=LEFT(A9)&TEXT(RIGHT(A9,LEN(A9)-1),"0000000")
 
Upvote 0
Thankyou Mark, that works great. Although it does not update the original column's values, I can use it in an if statement to run the check against the full 8 digit value.
 
Upvote 0

Forum statistics

Threads
1,213,564
Messages
6,114,334
Members
448,567
Latest member
Kuldeep90

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