DMQ
Thành viên dốt
- Tham gia
- 21/3/12
- Bài viết
- 722
- Được thích
- 57
- Giới tính
- Nam
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Muahanghoa")
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
If Trim(Me.TxtHH.Value) = "" Then
Me.TxtHH.SetFocus
MsgBox "Chua co ten hang hoa", vbInformation
Exit Sub
End If
ws.Cells(iRow, 1).Value = Me.TxtHH.Value
ws.Cells(iRow, 2).Value = Me.TxtDVT.Value
ws.Cells(iRow, 3).Value = Me.TxtSL.Value
ws.Cells(iRow, 4).Value = Me.TxtNB.Value
Me.TxtHH.Value = ""
Me.TxtDVT.Value = ""
Me.TxtSL.Value = ""
Me.TxtNB.Value = ""
Me.TxtHH.SetFocus
End Sub
[COLOR=#000000]iRow = ws.Cells(Rows.Count, 1) _
[/COLOR][COLOR=#000000] .End(xlUp).Offset(1, 0).Row[/COLOR]
[COLOR=#000000]iRow = ws.Cells(Rows.Count, 1) _
[/COLOR][COLOR=#000000] .End(xlUp).[/COLOR][B][COLOR=#ff0000]Offset(4, 3)[/COLOR][/B][COLOR=#000000].Row [/COLOR][B][COLOR=#0000ff]<- em chỉnh chổ này[/COLOR][/B]




1. Sửa lại tên các textbox là TB1, TB2... TB8Em đưa file lên mong các AC giúp em như trong file đính kèm, em có chỉnh code thành :
nhưng sao code lại ghi từ cột AMã:[COLOR=#000000]iRow = ws.Cells(Rows.Count, 1) _ [/COLOR][COLOR=#000000] .End(xlUp).[/COLOR][B][COLOR=#ff0000]Offset(4, 3)[/COLOR][/B][COLOR=#000000].Row [/COLOR][B][COLOR=#0000ff]<- em chỉnh chổ này[/COLOR][/B]
mong các AC giúp em.
Private Sub CommandButton1_Click()
Dim Kq(1 To 4), i&
With Me
If .TB1.Value = "" Then
MsgBox "chua co ten hang hoa", vbInformation
.TB1.SetFocus
Exit Sub
End If
For i = 1 To 4
Kq(i) = .Controls("TB" & i).Value
.Controls("TB" & i).Value = ""
Next
Sheet1.[D65536].End(3).Offset(1).Resize(, 4) = Kq
.TB1.SetFocus
End With
End Sub