How to run a Macro on Password Protected xl sheet veryhidden

RAJESH1960

Active Member
Joined
Mar 26, 2020
Messages
453
Office Version
  1. 2019
Platform
  1. Windows
Hi. The command button is in an active sheet, But it has to select data from a xl sheet very hidden in the same workbook. It showed an error when I tried to use the command button. How do I run the macro without un-protecting my sheet.
Untitled.png
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

RAJESH1960

Active Member
Joined
Mar 26, 2020
Messages
453
Office Version
  1. 2019
Platform
  1. Windows
Hi. The command button is in an active sheet, But it has to select data from a xl sheet very hidden in the same workbook. It showed an error when I tried to use the command button. How do I run the macro without un-protecting my sheet.
View attachment 17878
The macro runs perfectly without the protection. When I run the macro it copies the data from the very hidden xl sheet to be pasted and saved. I also do not want the code to be seen when error is debug.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,744
Office Version
  1. 365
Platform
  1. Windows
How do I run the macro without un-protecting my sheet.
You don't. What you do is have the Macro temporarily unprotect it, do its work, and then re-protect it.
So it is only unprotected for the very brief time while the macro is running (and with no user interaction).

You can see how to do that here: Unprotect sheet error in VBA
 

RAJESH1960

Active Member
Joined
Mar 26, 2020
Messages
453
Office Version
  1. 2019
Platform
  1. Windows
Hello Joe4. Thanks for the response . I got the solution.
Sheets("Sheet1").Activate

ActiveSheet.Unprotect "Hello"

‘Get the clipboard data

strData = .GetText

Sheets("Sheet1").Activate

ActiveSheet.Protect "Hello"
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,744
Office Version
  1. 365
Platform
  1. Windows
You are welcome.
 

Watch MrExcel Video

Forum statistics

Threads
1,128,117
Messages
5,628,790
Members
416,340
Latest member
PJB1102

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
Top