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

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

matts

New Member
Joined
Sep 11, 2002
Messages
41
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
 

Mark W.

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,654
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")
 

matts

New Member
Joined
Sep 11, 2002
Messages
41
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.
 

Forum statistics

Threads
1,144,743
Messages
5,726,022
Members
422,653
Latest member
mntsiki

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
Top