Copy data to several rows based on a number in a TextBox

epardo87

Board Regular
Joined
Feb 24, 2015
Messages
56
hi,
I have the code below, it transfers data into one excel row, I want to add another textbox (let's say RowsTextBox) so that all information is transferred as currently but copied in the following rows according to the qty at RowsTextBox.

Any suggestions?

Code:
Private Sub RegCommandButton_Click()
Dim emptyRow As Long
Sheet2.Activate
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
Dim bControlEmpty As Boolean
bControlEmpty = False
    If Len(ItemComboBox.Value) > 0 And Len(QtyTextBox.Value) > 0 And Len(AreaComboBox.Value) > 0 And Len(CauseComboBox.Value) > 0 Then
    Cells(emptyRow, 3).Value = ItemComboBox.Value
    Cells(emptyRow, 4).Value = QtyTextBox.Value
    Cells(emptyRow, 5).Value = AreaComboBox.Value
    Cells(emptyRow, 6).Value = CauseComboBox.Value
    Else
    bControlEmpty = True
    End If 
If bControlEmpty Then
    MsgBox "Complete form please"
Else        
    ThisWorkbook.Save       
    Unload Me    
 End If
End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,223,270
Messages
6,171,103
Members
452,379
Latest member
IainTru

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