Automatic Part Number Generator

Teddydoggy

New Member
Joined
Sep 24, 2017
Messages
2
Hello all,

First time posting here. I'm trying to create a part number generator in Excel. The part numbers are in the following format: "XXXXX-XX", where the first five digits are serialized numbers, and the trailing two digits are the revision level.

When a new part number is pulled, the revision level will always start from "01". e.g:"12345-01". I already have pre-existing part numbers in column "A", and my goal is to have Excel look through the entire "A" column, break the part numbers up and only look at the first 5 serialized digits, then identify the highest value, and automatically +1 to that value. And finally, add the trailing revision level "-01" to the newly generated part number. If my most recent part number was "12345-22", then a newly generated part number would be "12346-01".

This is what I have so far:
Code:
[/FONT]=MAX(VALUE(LEFT(A1:A11, 5))) +1 & "-01"[FONT=arial]

The code above works as long as I manually update the range (A1:A11). However, the part number list will be growing, so is there a way to make the input range dynamic? I've already tried (A:A), which includes all the empty cells in column "A", and the "Max" function returns "0" if there are any empty cells in your defined range. I also tried embedding a "Counta (A:A)" function in the formula but kept getting syntax errors.

Also, if I wanted to convert this into a VBA, and have the whole process run in the background, would I be able to simply copy the formula above into VBA? My end goal would be to just simply click a button, and the Macro automatically inserts a new row with the new part number.

Any help would be appreciated! Thanks in advance.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You can use this array-entered** formula although it would be more efficient if you decided on a maximum row number you would never exceed and use that in a fixed array in place of the A:A reference...

=MAX(IFERROR(1+LEFT(A:A,5),0))&"-01"

**Commit this formula using CTRL+SHIFT+ENTER and not just Enter by itself
 
Last edited:
Upvote 0
Thank you Rick. That worked beautifully!

You can use this array-entered** formula although it would be more efficient if you decided on a maximum row number you would never exceed and use that in a fixed array in place of the A:A reference...

=MAX(IFERROR(1+LEFT(A:A,5),0))&"-01"

**Commit this formula using CTRL+SHIFT+ENTER and not just Enter by itself
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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