epardo87
Board Regular
- Joined
- Feb 24, 2015
- Messages
- 56
Hello, well I have a UF working but each entry fills only one row, the problem is that I can't always place a single row of certain Item with a qty=4 (e.g.), instead I could need four rows with qty=1 each, or two rows with Qty 2, etc. (it varies according to the item).
So I need a TextBox where the number defines the maximum Qty so if I place QTY=4 and MaxQty = 1, then it transfers data to four rows with Qty= 1 (also require that if odd number, the last one contains fewer qty to avoid fractions)...
I'd really appreciate any help!
So this is the code, a little bit simplified, suppose that the new field is called MaxQtyTextBox
So I need a TextBox where the number defines the maximum Qty so if I place QTY=4 and MaxQty = 1, then it transfers data to four rows with Qty= 1 (also require that if odd number, the last one contains fewer qty to avoid fractions)...
I'd really appreciate any help!
So this is the code, a little bit simplified, suppose that the new field is called MaxQtyTextBox
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 Then
Cells(emptyRow, 3).Value = ItemComboBox.Value
Else
bControlEmpty = True
End If
If Len(QtyTextBox.Value) > 0 Then
Cells(emptyRow, 4).Value = QtyTextBox.Value
Else
bControlEmpty = True
End If
If bControlEmpty Then
MsgBox "Please complete all fields"
Else
Cells(emptyRow, 1).Value = Date
[COLOR=#ff0000]'This is the code for the consecutive number, don't know if would be affected by the Max Qty TextBox[/COLOR]
With Cells(emptyRow, 2)
.Value = Cells(emptyRow - 1, 2).Value + 1
End With
End If
End Sub