Hello Experts,
Below is my logic to copy/paste and sort data between two excel sheets.
Logic:
Have written my logics till here and Its not working, also need more coding in sorting the data
7. Deleting the empty row which got copied
8. Also need to write a sub logic where the data gets pasted in next lines for character if length is 8 & 6.
Below is my code:
Sub Engineering()
'If Length of coloumn B is 10
Dim Answer As VbMsgBoxResult
Answer = MsgBox("Are you sure to copy BOM contents?", vbYesNo, "Run Macro")
If Answer = vbYes Then
Workbooks("116132.xlsx").Worksheets("BOM").Range("A2:D31").Copy _
Workbooks("2.xlsx").Worksheets("MPL").Range("B16")
Workbooks("116132.xlsx").Worksheets("BOM").Range("I2:I31").Copy _
Workbooks("2.xlsx").Worksheets("MPL").Range("F16")
Dim Answer1 As Range
For Each Answer1 In Workbooks("2.xlsx").Worksheets("MPL").Range("B16:B45")
If Selection.Len = "10" Then
Next Answer1
If Selection.Len = "8" Then
Workbooks("2.xlsx").Worksheets("MPL").Rows(Selection).Copy _
Workbooks("2.xlsx").Worksheets("MPL").Range("A47")
Next Answer1
If Selection.Len = "6" Then
Workbooks("2.xlsx").Worksheets("MPL").Rows(Selection).Copy _
Workbooks("2.xlsx").Worksheets("MPL").Range("A55")
Next Answer1
End Sub
So basically need help
1. to understand the issue in my current code
2. How to increment the rows while pasting data for condition if character length = 8 & 6
Appreciate any help from this forum. Thanks
Below is my logic to copy/paste and sort data between two excel sheets.
Logic:
- Want to copy A2 to D31 in XL “116132” to B16 of “2”
- Want to copy I2 to I31 in XL “116132” to F16 of “2”
- Then I need to sort the data in XL “2” based on the condition.
- If Part number characters length is 10 then it should remain in its place
- If Part number characters length is 8 then it should copy data in that row and paste it from row A48
- If Part number characters length is 7 then it should copy data in that row and paste it from row A55
Have written my logics till here and Its not working, also need more coding in sorting the data
7. Deleting the empty row which got copied
8. Also need to write a sub logic where the data gets pasted in next lines for character if length is 8 & 6.
Below is my code:
Sub Engineering()
'If Length of coloumn B is 10
Dim Answer As VbMsgBoxResult
Answer = MsgBox("Are you sure to copy BOM contents?", vbYesNo, "Run Macro")
If Answer = vbYes Then
Workbooks("116132.xlsx").Worksheets("BOM").Range("A2:D31").Copy _
Workbooks("2.xlsx").Worksheets("MPL").Range("B16")
Workbooks("116132.xlsx").Worksheets("BOM").Range("I2:I31").Copy _
Workbooks("2.xlsx").Worksheets("MPL").Range("F16")
Dim Answer1 As Range
For Each Answer1 In Workbooks("2.xlsx").Worksheets("MPL").Range("B16:B45")
If Selection.Len = "10" Then
Next Answer1
If Selection.Len = "8" Then
Workbooks("2.xlsx").Worksheets("MPL").Rows(Selection).Copy _
Workbooks("2.xlsx").Worksheets("MPL").Range("A47")
Next Answer1
If Selection.Len = "6" Then
Workbooks("2.xlsx").Worksheets("MPL").Rows(Selection).Copy _
Workbooks("2.xlsx").Worksheets("MPL").Range("A55")
Next Answer1
End Sub
So basically need help
1. to understand the issue in my current code
2. How to increment the rows while pasting data for condition if character length = 8 & 6
Appreciate any help from this forum. Thanks