Showing posts with label Unprotect Worksheets using VBA. Show all posts
Showing posts with label Unprotect Worksheets using VBA. Show all posts

Saturday, September 24, 2011

Unprotect Worksheets using VBA

If you want to unprotect worksheets using VBA.

Here is the code-

Sub upprotect_all_worksheets()
Dim wk As Worksheet
For Each wk In ThisWorkbook.Sheets
wk.Unprotect "password"
Next wk
End Sub

Sub unprotect_specific_worksheets()
'it will UNprotect all sheets which will be added to Array("Sheet1", "Sheet2") list
Dim abc()
Dim wk As Worksheet
Dim i As Integer
abc = Array("Sheet1", "Sheet2")
For i = LBound(abc) To UBound(abc)
For Each wk In ThisWorkbook.Sheets
If wk.Name = abc(i) Then
wk.Unprotect "password"
Exit For
End If
Next wk
Next i
End Sub

Import data from SQL

Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...