Adding serial number

Gwilliams57

New Member
Joined
Feb 27, 2018
Messages
4
I need to change my ERP system to a serialized inventory system, i have list of products and their total quantity. all i am trying to do is take a product and if the total quantity is 10, create 10 records so i can assign a unique number to each product.

Example of data i have:
2018 Catalog10

<tbody>
</tbody>

can i do this in excel ( i am so bad in excel), i currently have 2075 products with a 125k total.

i could use some help

thank you


EDIT: Same question posted in Access forum here: https://www.mrexcel.com/forum/microsoft-access/1045376-adding-serial-number.html
 
Last edited by a moderator:

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi,

Try this: https://www.dropbox.com/s/ymb35tsavk8iijf/GWilliams 57-Adding Serial Number.xlsm?dl=0



It takes your data from Sheet1 and creates [Qty] x number of items, per item in Sheet 2.


Below is the code

NB: Make sure you don't want anything in SHEET2 before running, as it clears the contents of that sheet in order to put new data into it!


Code:
Sub test()


    Const SrcSheet = "Sheet1"
    Const TgtSheet = "Sheet2"


    Dim rng As Range, Data()
    Dim LastRow As Long, TgtMrkRow As Long, Cntr As Long, QtyCntr As Long
    
    LastRow = Sheets(TgtSheet).Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
    Sheets(TgtSheet).Range("2:" & LastRow).ClearContents
    
    LastRow = Sheets(SrcSheet).Range("A:B").Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
    Set rng = Sheets(SrcSheet).Range("A2:B" & LastRow)
    
    Data = rng
    
    TgtMrkRow = 1
    For Cntr = 1 To UBound(Data)
        For QtyCntr = 1 To Data(Cntr, 2)
            TgtMrkRow = TgtMrkRow + 1
            Sheets(TgtSheet).Range("A" & TgtMrkRow) = Data(Cntr, 1)
            Sheets(TgtSheet).Range("B" & TgtMrkRow) = QtyCntr
            Sheets(TgtSheet).Range("C" & TgtMrkRow) = Data(Cntr, 2)
        Next QtyCntr
    Next Cntr
    
    MsgBox "Done"


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,225
Messages
6,123,732
Members
449,116
Latest member
Aaagu

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