Protect

KlausW

Active Member
Joined
Sep 9, 2020
Messages
390
Office Version
  1. 2016
Platform
  1. Windows
Hi
I have a challenge
I would like to protect a closed Excel Workbook, from an open Excel Workbook, where the name of the Workbook I would like to protect is in the sheet prisliste cell J4
I have tried this code but can't get it to work.
Some who can help
Any help will be appreciated
Best regards
Klaus W
VBA Code:
Sub vba_protect_workbook()

'declare varibale to use for the workbook

Dim wb As Workbook

'open the workbook that you want to protect

Set wb = Workbooks.Open Range (“J4”)

'turn off the screen-updating to _

done everything in the backend

Application.ScreenUpdating = False

'protect the workbook

wb.Protect

'close the workbook after protecting

wb.Close savechanges = True 'turn off the screen-updating

Application.ScreenUpdating = True

End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,215,692
Messages
6,126,227
Members
449,303
Latest member
grantrob

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top