studentpro
New Member
- Joined
- May 20, 2016
- Messages
- 8
I am a pharmacy student in serious need of help for my internship.
I need a macro/vba code that auto generates when there is cell content in a row of a worksheet. this number is going to be an invoice number. I current have a 'masterfile' that records all finalized orders for each facility. Every row represents 1 order.
I need a code to generate a number that looks like this: CD-1000
the "CD-" is fixed and won't change, but the "1000" needs to be unique for every row line
in the masterfile, columns A thru J are auto-populated with the finalized order and I want column K to be where the invoice number lives.
I want the code to work something like this:
find empty cell in column k_generate invoice # for columns cells K based on last previous cell invoice # for all column k cells that have content in row to the left and stop generating when rows are empty. the invoice number that generated should never be used again even if its not in the masterfile any more and a row's invoice number should never be changed/recalculated when the code runs again.
I have already tried the vba that references the first cell in column K then adds +1 down, but that does not work because it either produced a duplicate number already used, or every time the macro ran, it would recalculate every cell in column k which would change an order invoice because an order can be deleted from the masterfile but that order still exist in other reports.
Any ideas on how to set this up? I would appreciate any help or suggestions!
I need a macro/vba code that auto generates when there is cell content in a row of a worksheet. this number is going to be an invoice number. I current have a 'masterfile' that records all finalized orders for each facility. Every row represents 1 order.
I need a code to generate a number that looks like this: CD-1000
the "CD-" is fixed and won't change, but the "1000" needs to be unique for every row line
in the masterfile, columns A thru J are auto-populated with the finalized order and I want column K to be where the invoice number lives.
I want the code to work something like this:
find empty cell in column k_generate invoice # for columns cells K based on last previous cell invoice # for all column k cells that have content in row to the left and stop generating when rows are empty. the invoice number that generated should never be used again even if its not in the masterfile any more and a row's invoice number should never be changed/recalculated when the code runs again.
I have already tried the vba that references the first cell in column K then adds +1 down, but that does not work because it either produced a duplicate number already used, or every time the macro ran, it would recalculate every cell in column k which would change an order invoice because an order can be deleted from the masterfile but that order still exist in other reports.
Any ideas on how to set this up? I would appreciate any help or suggestions!