Duplicate row and insert information from inputbox

Prashant1211

New Member
Joined
Jun 9, 2020
Messages
33
Office Version
  1. 2016
Platform
  1. Windows
Hello Excel programmers, I have a excel file contain list of x number of products with n qty. to be packed in separate boxes. Some products can be packed in single box and some need to be multiple boxes because of high qty. Now i am trying to split the qty. so that i can pack it in different boxes. My requirement is when user run the macro then, below selected row a new row should be inserted with new box no. and qty.

After User select the row on selected row Macro should function like -

- Delete packing box no. of selected row and move the total qty in any empty cell
- an input box should appear to enter box no and qty. with tab "Submit"
- when user Submit the input first time. The information should go in selected row. The qty entered to be verified with Total qty (moved to empty cell in step 1)
- if the qty is less than again Input box should appear to enter new box no. and qty. This will be the second time user input the information so this time selected row to be copied and inserted below it. The information submitted second time should go in the newly inserted row. and this should continue unless full qty. is packed

I am in the learning stage and do not have much command on VBA and request for help.

below is my code. it duplicate the selected row in no. of time i enter. but this does not serve my full purpose. Can anyone help.


Sub Duplicaterow()

Dim xCount As Integer
LableNumber:
xCount = Application.InputBox("Number of Boxes", "Packing List", , , , , , 1)
If xCount < 1 Then
MsgBox "the entered number of box are not correct, please enter again"
GoTo LableNumber
End If



ActiveCell.EntireRow.Copy
Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(xCount, 0)).EntireRow.Insert Shift:=xlDown

Application.CutCopyMode = False
End Sub
 

Attachments

  • image.jpg
    image.jpg
    11 KB · Views: 8

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,215,840
Messages
6,127,215
Members
449,370
Latest member
kaiuuu

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