Excel 2013 Password Protection Pissing me off Again !

spurs

Active Member
Joined
Oct 18, 2006
Messages
469
Office Version
  1. 2016
  2. 2013
  3. 2010
  4. 2007
  5. 2003 or older
Platform
  1. Windows
I have the following macro that runs on SOME machines with excel 2013 but not all.

This macro always works if you step through the macro line by line, but does not work if you run the macro full speed starting with the worksheet protected. If the worksheet starts in unprotected mode it works in full speed.



Sub Inc_Dec()
' This subroutine adds a decimal place to the units
Dim Num_Dec As Integer

Num_Dec = Range("A1").Value

Select Case Num_Dec
Case 0
Dec = "0.0"
Case 1
Dec = "0.00"
Case 2
Dec = "0.000"
Case 3
Dec = "0.0000"
Case 4
Dec = "0.00000"
Case Else
GoTo 100
End Select

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual ' turns off autmatic spreadsheet calculation

Sheets("Test Geometry (in)").Unprotect "1234"
Sheets("Test Geometry (mm)").Unprotect "1234"


Range("A1") = Num_Dec + 1 ' note 6 dec place is the maximum

Range("D19:G19").NumberFormat = Dec
Range("C27:I36").NumberFormat = Dec
Range("G37:G39").NumberFormat = Dec
Range("G41:G41").NumberFormat = Dec
Range("C42:F44").NumberFormat = Dec
Range("G44:I45").NumberFormat = Dec
Range("D48:I52").NumberFormat = Dec

Sheets("Test Geometry (in)").Protect "1234"
Sheets("Test Geometry (mm)").Protect "1234"

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

100 End Sub


Any thoughts on how to make this work - and still use password protection on the worksheets?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
after turning password off, add DoEvents
 
Upvote 0
DoEvents did not do anything

I added it after every password unprotect line and again after every protect line
 
Upvote 0
Why do you unprotect two sheets then alter the number format on whatever happens to be the active sheet?
 
Upvote 0
Because the macro is initiated from either of the two sheets and I only want the active sheet to be changed.
This worked ok in excel 2003, I found that for excel 2013 I have to first set the active sheet and then unprotect only the active sheet, then it works
 
Upvote 0

Forum statistics

Threads
1,203,461
Messages
6,055,561
Members
444,799
Latest member
CraigCrowhurst

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