mir994stan
New Member
- Joined
- Jul 18, 2021
- Messages
- 42
- Office Version
- 2016
- Platform
- Windows
Greetings to everyone,
I completed my workbook project, all works great and autonomous as expected, but i would like to add one more feature to it. I was looking whole day on forums and youtube, but coludn t find anything similar, i do some VBA but, i rly can t handle this, and i could use some help. I tried with xlookup, match, index but it can t be solved with functions... Its little complicated question but i will try to explain it good.
I will put sample workbook with data and document tamplate, i also recored a macro while i was manualy doing this job, just for preview of whats required.
Sample WB: Link to sample Workbook
I have 3 sheets, "ForDelivery", "Document1" and "Document2". Sheet "ForDelivery" contain shipment data in range "A:F" in column "A" are product names and in column "B" are serial numbers, so in range "B:F" are informations for that product.
Document sheets, 1 and 2 needs to be populated with corensponding values from "For delivery" sheet in column range "G:K" starting from row 19 and down. So i need a macro that will search for product name in document sheets, column B is where names are, and if there is a match, copy values from range "B:F" in Sheet "ForDelivery" to row in document sheet where name was found in ragne "G:K", so values from column B goes to column G, C to H, and etc..
I made this work with XLookup, but problem where function can t work is when i have more then one serial number for one product name. Column "B" in Sheet "ForDelivery" contain serial numbers for each product, main purpose of macro is to insert new row under existing row if there are more then one serial number, copy formulas from above in columns D and E, and if possible to merge cells in columns A,B,C and F with cells in new row.
As always, thanks in advance.
Code i made with macro recored
I completed my workbook project, all works great and autonomous as expected, but i would like to add one more feature to it. I was looking whole day on forums and youtube, but coludn t find anything similar, i do some VBA but, i rly can t handle this, and i could use some help. I tried with xlookup, match, index but it can t be solved with functions... Its little complicated question but i will try to explain it good.
I will put sample workbook with data and document tamplate, i also recored a macro while i was manualy doing this job, just for preview of whats required.
Sample WB: Link to sample Workbook
I have 3 sheets, "ForDelivery", "Document1" and "Document2". Sheet "ForDelivery" contain shipment data in range "A:F" in column "A" are product names and in column "B" are serial numbers, so in range "B:F" are informations for that product.
Document sheets, 1 and 2 needs to be populated with corensponding values from "For delivery" sheet in column range "G:K" starting from row 19 and down. So i need a macro that will search for product name in document sheets, column B is where names are, and if there is a match, copy values from range "B:F" in Sheet "ForDelivery" to row in document sheet where name was found in ragne "G:K", so values from column B goes to column G, C to H, and etc..
I made this work with XLookup, but problem where function can t work is when i have more then one serial number for one product name. Column "B" in Sheet "ForDelivery" contain serial numbers for each product, main purpose of macro is to insert new row under existing row if there are more then one serial number, copy formulas from above in columns D and E, and if possible to merge cells in columns A,B,C and F with cells in new row.
As always, thanks in advance.
Code i made with macro recored
VBA Code:
Sub COPY_INSERT_ROWS()
'
' Code added for faster run
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
'------------------------------------------
Sheets("ForDelivery").Select
Range("B19:F19").Select
Selection.Copy
Sheets("Document1").Select
Range("G34:K34").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("ForDelivery").Select
Range("B2:F2").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Document1").Select
Range("G24:K24").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("24:24").Select
Range("B24").Activate
Application.CutCopyMode = False
Selection.Copy
Rows("25:25").Select
Range("B25").Activate
Selection.Insert Shift:=xlDown
Sheets("ForDelivery").Select
Range("B3:F3").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Document1").Select
Range("G25:K25").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("F24:F25,C24:C25,B24:B25,A24:A25").Select
Range("B25").Activate
Application.CutCopyMode = False
Selection.Merge
'---------------------------------------
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
End Sub