Code nhập lệnh vào Sheet "QLGD"
===================================================
Private Sub CommandButton1_Click()
Dim strLastRow As Integer
'Get last row
strLastRow = xlLastRow("QLGD")
With UserForm5
'If textboxes not null then fill data of textboxes to worksheet.
If (.TextBox11.Value <> vbNullString And .OptionButton1.Value = True) Then
Cells(strLastRow + 1, 1).Value = UserForm5.TextBox12.Value
Cells(strLastRow + 1, 2).Value = UserForm5.Label22.Value
Cells(strLastRow + 1, 3).Value = "Mua CP"
Cells(strLastRow + 1, 4).Value = UserForm5.TextBox9.Value
Cells(strLastRow + 1, 5).Value = UserForm5.TextBox10.Value
Cells(strLastRow + 1, 6).Value = UserForm5.TextBox11.Value
strLastRow = strLastRow + 1
Else
If .OptionButton2.Value = True Then
Cells(strLastRow + 1, 1).Value = UserForm5.TextBox12.Value
Cells(strLastRow + 1, 2).Value = UserForm5.Label22.Value
Cells(strLastRow + 1, 3).Value = "Ban CP"
Cells(strLastRow + 1, 4).Value = UserForm5.TextBox9.Value
Cells(strLastRow + 1, 5).Value = UserForm5.TextBox10.Value
Cells(strLastRow + 1, 6).Value = UserForm5.TextBox11.Value
strLastRow = strLastRow + 1
Else
MsgBox = "Vui long dien day du 5 o^ !"
End With
Unload Me
End Sub
===================================================
Bạn Doom ơi, giúp mình sửa code cho CommandButton1 với, máy báo lỗi ở mấy phần chữ đỏ.
- Ý mình là: Nếu chọn Option Button 1 (MUA) thì nó sẽ ghi vào cột C - Sheet QLGD là "Mua CP"
Nếu chọn Option Button 2 (BÁN) thì nó sẽ ghi vào cột C - Sheet QLGD là "Ban CP"
Chưa chọn thì nó báo lỗi " Vui long dien day du 5 ô !"
Và để ghi ra tên TK vào cột B nữa.
P/S: Mình cũng thử sửa search => search1 nhưng vẫn chưa đc, type vào mà vẫn ko search đc