Mình mới nhập môn VBA. Cả nhà giúp chỉ giúp mình lỗi đoạn code này với a.
Option Explicit
Sub Luuvaodata()
Dim lr As Long, i As Long
'Kiem tra dieu kien
For i = 5 To 17
If Shfrom.Range("F" & i).Value = False Then
MsgBox Shfrom.Range("H" & i).Value
Shfrom.Range("B" & i).Select
Exit Sub
End If
Next i
'Luu vao data
With shdata
lr = .Range("A" & Rows.Count).End(xlUp).Row + 1
Shfrom.Range("AA6:AM6").Copy 'copy
.Range("A" & lr).PasteSpecial xlPasteValues 'paste
Application.CutCopyMode = False
reset 'xoa nhap lai tu dau
MsgBox "Xong!"
Shfrom.Range("B5") = "=MAX('data Ke toan'!A1)+1"
.Range("B8") = "=IFERROR(VLOOKUP(B7;'danh sach'!$G$2:$H$259;2;0);"")"
End With
End Sub
Sub reset()
With Shfrom
.Range("b6;b16").ClearContents
.Range("B5") = "=MAX('data Ke toan'!A1)+1"
End With
End Sub
Option Explicit
Sub Luuvaodata()
Dim lr As Long, i As Long
'Kiem tra dieu kien
For i = 5 To 17
If Shfrom.Range("F" & i).Value = False Then
MsgBox Shfrom.Range("H" & i).Value
Shfrom.Range("B" & i).Select
Exit Sub
End If
Next i
'Luu vao data
With shdata
lr = .Range("A" & Rows.Count).End(xlUp).Row + 1
Shfrom.Range("AA6:AM6").Copy 'copy
.Range("A" & lr).PasteSpecial xlPasteValues 'paste
Application.CutCopyMode = False
reset 'xoa nhap lai tu dau
MsgBox "Xong!"
Shfrom.Range("B5") = "=MAX('data Ke toan'!A1)+1"
.Range("B8") = "=IFERROR(VLOOKUP(B7;'danh sach'!$G$2:$H$259;2;0);"")"
End With
End Sub
Sub reset()
With Shfrom
.Range("b6;b16").ClearContents
.Range("B5") = "=MAX('data Ke toan'!A1)+1"
End With
End Sub