yome
GPE thật tuyệt vời
- Tham gia
- 9/5/08
- Bài viết
- 347
- Được thích
- 113
Anh/chị sửa dùm em đoạn code này:
Tuy nó vẫn cập nhật nhưng nó vẫn hiện ra thông báo lỗi.
Mã:
[FONT=Times New Roman][SIZE=3]Private Sub CommandButton1_Click()[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Dim iRow As Long[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Dim ws As Worksheet[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Set ws = Worksheets("Data")[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row[/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] If Trim(Me.ComboBox1.Value) = "" Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Me.ComboBox1.SetFocus[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] MsgBox "Ma vat lieu khong duoc de trong ", vbCritical + vbOKOnly[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Exit Sub[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]End If[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]With ws[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3].Cells(iRow, 1) = Me.TextBox1[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3].Cells(iRow, 2) = Me.TextBox2[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]'.Cells(iRow, 2).Value = Format(Me.TextBox2.Value, "DD/MM/YYYY")[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3].Cells(iRow, 3) = Me.ComboBox1[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3].Cells(iRow, 4) = Me.TextBox4[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3].Cells(iRow, 5) = Me.TextBox5[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3].Cells(iRow, 6) = Me.ComboBox3[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3].Cells(iRow, 7) = Val(Format(Me.TextBox7, "0"))[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3].Cells(iRow, 8 + IIf(Me.ComboBox2 = "PN", 0, 2)).Value = Val(Format(Me.TextBox8, "0"))[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3].Cells(iRow, 9 + IIf(Me.ComboBox2 = "PN", 0, 2)).Value = Val(Format(Me.TextBox9, "0"))[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]End With[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]For j = 1 To 9[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]If j = 3 Then[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]ComboBox1 = ""[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Else[/SIZE][/FONT]
[B][COLOR=red][SIZE=3][FONT=Times New Roman]Me.Controls("TextBox" & j) = ""[/FONT][/SIZE][/COLOR][/B]
[FONT=Times New Roman][SIZE=3]End If[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Next[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Me.TextBox1.SetFocus[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]End Sub[/SIZE][/FONT]