vantiep1002
Thành viên mới

- Tham gia
- 11/8/09
- Bài viết
- 6
- Được thích
- 0
Các bác coi hộ em đoạn cod này sai chỗ nào mà không protect và unproct sheet2 duọc nhỉ.
cod:
' mo password truoc khi nhap du lieu
Sub UnprotectSheet2()
ActiveSheet2.Unprotect Password:="123"
End Sub
Sub NhapDL()
Dim i, j, Cl As Range
j = Sheet2.[B65536].End(3).Row + 1
If j < 6 Then j = 6
'Kiem tra
For i = 4 To 20
If Sheet1.Cells(i, 4) = "" Then
If i <> 6 And i <> 7 And i <> 20 Then
MsgBox "Thieu thong tin:"
Exit Sub
End If
End If
Next
'Nhap Sheet thong tin KH
For i = 4 To 20
Sheet2.Cells(j, i - 2) = Sheet1.Cells(i, 4)
Next
'Don dep
Sheet1.[D6
10].ClearContents
Sheet1.[D14
16].ClearContents
Sheet1.[D19
19].ClearContents
Sheet1.[D6].Select
End Sub
' Khoa password sau khi nhap du lieu
Sub protectSheet2()
ActiveSheet2.Protect Password:="123"
End Sub
cod:
' mo password truoc khi nhap du lieu
Sub UnprotectSheet2()
ActiveSheet2.Unprotect Password:="123"
End Sub
Sub NhapDL()
Dim i, j, Cl As Range
j = Sheet2.[B65536].End(3).Row + 1
If j < 6 Then j = 6
'Kiem tra
For i = 4 To 20
If Sheet1.Cells(i, 4) = "" Then
If i <> 6 And i <> 7 And i <> 20 Then
MsgBox "Thieu thong tin:"
Exit Sub
End If
End If
Next
'Nhap Sheet thong tin KH
For i = 4 To 20
Sheet2.Cells(j, i - 2) = Sheet1.Cells(i, 4)
Next
'Don dep
Sheet1.[D6

Sheet1.[D14

Sheet1.[D19

Sheet1.[D6].Select
End Sub
' Khoa password sau khi nhap du lieu
Sub protectSheet2()
ActiveSheet2.Protect Password:="123"
End Sub