VBA error message

julianchan58

New Member
Joined
Sep 11, 2019
Messages
2
Hi all,

My VBA used to run with no issue, but recently seeing "System Error &H80070057 (-2147024809)"

VBA simply protect all worksheets in the workbook. Am currently using Office 365 (running under Win10) . Any clue what could have caused the issue? many thanks!!!!!
__________________________________________
Sub protectsheet()
Dim ws As Worksheet
Dim pw As Variant


pwd = "finBkk20" ' Put your password here


For Each ws In Worksheets
ws.protect Password:=pwd
Next ws


Worksheets("Instruction").Activate


MsgBox ("All sheets protected")


End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi juliianchan58


I am not sure if this will help, this:
If this is a copy and paste of your macros, then this mightbe the reason - add the "d".

Sub protectsheet()
Dim ws As Worksheet
Dim
pwd As Variant


pwd = "finBkk20" ' Put your password here


For Each ws In Worksheets
ws.protect Password:=pwd
Next ws


Worksheets("Instruction").Activate


MsgBox ("All sheets protected")


End Sub


 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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