tranthanh2200
Thành viên hoạt động
Em mới tập tành nhưng gặp lỗi mà không hiểu sửa sao cho đúng a.
Sub cap_quyen_login()
'Tao ten E5 den L5
Sheet1.Range("E7") = Sheet1.Name
Sheet1.Range("F7") = Sheet2.Name
Sheet1.Range("G7") = Sheet3.Name
Sheet1.Range("H7") = Sheet4.Name
Sheet1.Range("I7") = Sheet5.Name
Sheet1.Range("j7") = Sheet6.Name
'Khai bien
Dim hang As Integer 'hang cua user dang nhap
Dim cot As Integer ' Cot cua sheet 5 den 12
Dim tensheet As String 'ten sheet
hang = Sheet1.Range("O1")
For cot = 5 To 12
'Tu hang 7 den "cot"
tensheet = Sheet1.Cells(6, cot)
' cap quyen
If Sheet1.Cells(hang, cot) = 1 Then
Sheets(tensheet).Visible = xlSheetVisible
Sheets(tensheet).Unprotect "1"
End If
If Sheet1.Cells(hang, cot) = 2 Then
Sheets(tensheet).Visible = xlSheetVisible
Sheets(tensheet).Protect "1"
End If
If Sheet1.Cells(hang, cot) = 3 Then
Sheets(tensheet).Visible = xlSheetVeryHidden
Sheets(tensheet).Protect "1"
End If
Next
End Sub
Sub cap_quyen_login()
'Tao ten E5 den L5
Sheet1.Range("E7") = Sheet1.Name
Sheet1.Range("F7") = Sheet2.Name
Sheet1.Range("G7") = Sheet3.Name
Sheet1.Range("H7") = Sheet4.Name
Sheet1.Range("I7") = Sheet5.Name
Sheet1.Range("j7") = Sheet6.Name
'Khai bien
Dim hang As Integer 'hang cua user dang nhap
Dim cot As Integer ' Cot cua sheet 5 den 12
Dim tensheet As String 'ten sheet
hang = Sheet1.Range("O1")
For cot = 5 To 12
'Tu hang 7 den "cot"
tensheet = Sheet1.Cells(6, cot)
' cap quyen
If Sheet1.Cells(hang, cot) = 1 Then
Sheets(tensheet).Visible = xlSheetVisible
Sheets(tensheet).Unprotect "1"
End If
If Sheet1.Cells(hang, cot) = 2 Then
Sheets(tensheet).Visible = xlSheetVisible
Sheets(tensheet).Protect "1"
End If
If Sheet1.Cells(hang, cot) = 3 Then
Sheets(tensheet).Visible = xlSheetVeryHidden
Sheets(tensheet).Protect "1"
End If
Next
End Sub