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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,214,606
Messages
6,120,488
Members
448,967
Latest member
visheshkotha

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