Password protecting excel with macros

Z A Mustafa

New Member
Joined
Dec 8, 2013
Messages
5
Hi,

I am trying to protect one of my workbooks having 7-8 sheets in it.

When I password protect the workbook and open it again, the macros become disfunctional and my cells with VLOOKUP too dont work.

How do I protect the workbook, but also be able to have functional macros and Vlookup.

Your help would be greatly appreciated.

Regards,
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
If your macros are in the worksheets, like sheetchange or selectionchange events, you will need to incorporate a worksheet.unprotect / reprotect into those macros
So the code will unprotect the sheet / do the processes / reprotect the sheet
 
Upvote 0
Thanks for this Michael.

If it's not too much to ask, will you be able to help me with the code for the same?

P.S. - I am not too familiar with codes, so at times these codes go above my head.

Thanks & Regards,
Mustafa
 
Upvote 0
Ok, What codes do you have so far ?
AND
where do the codes reside ??
 
Upvote 0
The codes are VB codes, that run simple tasks like going to next sheet, back to previous sheet and print command.

The codes reside on the VBA Project (hope this is correct) of the same workbook.

Regards,
Mustafa
 
Upvote 0
OK, post one of them and we'll modify it for you.....then you will be able to modify the rest yourself.
 
Upvote 0
One of the codes is as follows:

I tried password protecting the workbook previously through the FILE menu and hence that error that popped up as mentioned above.

----------Example Macro code---------
' Todays date entered when clicked
Sub ProjectInfoQuoteDate()
ActiveSheet.Range("C5").Value = Date 'Get today's date
End Sub

Sub Page1_Click_Next()
' Page1_Click_Next Macro

Range("L19").Select
Sheets("Racks").Select
End Sub

-----------------------------
Thanks,
Mustafa
 
Upvote 0
Try
Code:
Sub ProjectInfoQuoteDate()
With ActiveSheet
.Unprotect Password:="password"
.Range("C5").Value = Date 'Get today's date
.Protect Password:="password"
End With
End Sub
 
Upvote 0
it is worth noting that excel's password security is not especially rigorous and easily bypassed, so good for stopping general fiddling, but not for commercial secrecy
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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