Hi guys,
Can somebody help me to combine the code in red with the code in blue.
This is what i would like achieve:
If the textbox "txtQty" is blank exit sub, but if "txtQty" textbox has a value and "sw1" combobox is blank then "sw1.Value = CommandButton5.Caption" but if "txtQty" textbox has a value and "sw1" combobox has a value then sw2.Value = CommandButton5.Caption. But if the combobox "cmbOnline".Value = "Standard" Then execute code in blue.
I'm so stuck, I would appreciate any help.
Thanks in advance
Private Sub CommandButton5_Click()
If txtQty = "" Then
Exit Sub
ElseIf sw1 = "" Then
sw1.Value = CommandButton5.Caption
Else: sw2.Value = CommandButton5.Caption
End If
Otherwise execute code below:
If Trim(Me.cmbOnline.Value) = "Standard" Then
Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("DataBase")
'find first row in database
irow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Range("A" & irow) = cmbDate.Value
.Range("B" & irow) = txtTime.Value
.Range("C" & irow) = cmbOperator
.Range("D" & irow) = cmbLine.Value
.Range("E" & irow) = txtOrder.Value
.Range("F" & irow) = txtPart.Value
.Range("G" & irow) = txtDescription
.Range("H" & irow) = txtQty.Value
.Range("I" & irow) = txtUom
.Range("K" & irow) = txtComments
.Range("J" & irow) = CommandButton4.Caption
If sw1 = "" Then
sw1.Value = CommandButton5.Caption
Else: sw2.Value = CommandButton5.Caption
Me.txtOrder.SetFocus
Me.txtOrder.SelStart = 0
Me.txtOrder.SelLength = Len(Me.txtOrder.Text)
End If
End With
End Sub
Bookmarks