PDA

View Full Version : Solved: Copy row with condition thru userform



slamet Harto
08-29-2008, 03:59 AM
Hi Expert,

Can you advise me on how to copied row if the combobox changed with BOTH then copied to new row.

Please find the attached file for your reference.
Many thanks in advance.
Rgds, Harto

Bob Phillips
08-29-2008, 05:02 AM
Private Sub CommandButton1_Click()
Dim Nrow As Integer
With Sheets(1)

Nrow = WorksheetFunction.CountA(.Range("B:B")) + 4

.Cells(Nrow, 1).Value = .Cells(Nrow - 1, 1).Value + 1
If ComboBox1.Value = "BOTH" Then
.Cells(Nrow, 2).Value = "AAAA"
.Cells(Nrow, 3).Value = TextBox2.Text
.Cells(Nrow, 4).Value = TextBox3.Text
.Cells(Nrow, 5).Value = TextBox4.Text
.Cells(Nrow, 6).Value = TextBox5.Text
Nrow = Nrow + 1
.Cells(Nrow, 1).Value = .Cells(Nrow - 1, 1).Value + 1
.Cells(Nrow, 2).Value = "BBBB"
.Cells(Nrow, 3).Value = TextBox2.Text
.Cells(Nrow, 4).Value = TextBox3.Text
.Cells(Nrow, 5).Value = TextBox4.Text
.Cells(Nrow, 6).Value = TextBox5.Text
Else
.Cells(Nrow, 2).Value = ComboBox1.Value
.Cells(Nrow, 3).Value = TextBox2.Text
.Cells(Nrow, 4).Value = TextBox3.Text
.Cells(Nrow, 5).Value = TextBox4.Text
.Cells(Nrow, 6).Value = TextBox5.Text
End If
Call getfocus
End With

End Sub

slamet Harto
08-31-2008, 07:18 PM
Thanks Bob.
Appreciate it so much.

Best, Harto