Hello graiggoriz,
The macro code below can be called from your current macro. You should change the password, worksheet name, and table names to match what you will be using.
Add a new VBA module to your workbook and paste the code into it. Add calls to this macro in your existing code where needed.
Sub Macro2(ByVal bLocked As Boolean)
Dim pwd As String
Dim oTable As Variant
Dim Wks As Worksheet
pwd = "Password" ' Change this to match your worksheet's password.
Set Wks = Worksheets("Sheet1") ' Change the name to the worksheet with the Tablea.
Wks.Unprotect pwd
For Each oTable In Array("Table1", "Table2", "Table4", "Table5")
Set oTable = Wks.ListObjects(oTable)
oTable.DataBodyRange.Cells.Locked = bLocked
Next oTable
Wks.Protect pwd
End Sub
Calling Examples
' Unlock the table cells.
Call Macro2(False)
' Lock th3e Table cells.
Call Macro2(True)
Bookmarks