Protect Worksheet in Ms. Excel

Cara untuk memprotect worksheet excel sehingga sheet hanya bisa read only
Buka Ms Excel > rename sheet1=contoh
klik tab developer>visual basic>klik 2x pada worksheet contoh
ketikkan kode berikut di worksheet contoh

Private Sub Worksheet_Activate()
Dim contoh As Worksheet
Dim myPassword As String
myPassword = "password"
For Each Sh In ActiveWorkbook.Worksheets
contoh.Protect Password:=myPassword
Next contoh
End Sub

Agar sheet di excel bisa di edit harus ketikkan kode berikut di lembar module pada visual basic editor:

Sub UnprotectAll()
Dim contoh As Worksheet
Dim myPassword As String
myPassword = "password"
For Each contoh In ActiveWorkbook.Worksheets
contoh.Unprotect Password:=myPassword
Next Sh
End Sub

untuk membuka worksheet yang telah dikunci, setelah menulis coding diatas kita tinggal memanggil fungsi diatas akan mengedit dengan mengetikan coding sbg berikut:

call UnprotectAll


Semoga bermanfaat.

Komentar

Postingan Populer