Danielt949
New Member
- Joined
- Jun 28, 2023
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
Afternoon all.
I am having issues with a Macro not unprotecting a worksheet.
If i manually unprotect the worksheet "Dashboard" via the bottom tabs, My macro button will open the userform no dramas.
When i close the userform to test the macro to make sure it has protected "Dashboard" as it should have, it is good.
However if i use the button to open userform again (with "Dashboard") still protected, The button will not unlock it. Coming up with a protection error.
Again, i manually unprotect, test button and it works, The form opens up.
I close the form again and test the "Dashboard"and it is locked again as it should be.
Again i can not open the userform as it wont unprotect.
I know the above is written twice, however this is purely to demonstrate the situation i am going through when testing the macro.
The weirder part is.... The macro is a "Copy and Paste" from a macro that is working, still working and not playing up, the only thing changed is the macro name. (Which is not the same as the module name)
NOTE - I have also tried using ActiveSheet.Unprotect "1" and this did not work.
Please Help
Cheers
I am having issues with a Macro not unprotecting a worksheet.
If i manually unprotect the worksheet "Dashboard" via the bottom tabs, My macro button will open the userform no dramas.
When i close the userform to test the macro to make sure it has protected "Dashboard" as it should have, it is good.
However if i use the button to open userform again (with "Dashboard") still protected, The button will not unlock it. Coming up with a protection error.
Again, i manually unprotect, test button and it works, The form opens up.
I close the form again and test the "Dashboard"and it is locked again as it should be.
Again i can not open the userform as it wont unprotect.
I know the above is written twice, however this is purely to demonstrate the situation i am going through when testing the macro.
The weirder part is.... The macro is a "Copy and Paste" from a macro that is working, still working and not playing up, the only thing changed is the macro name. (Which is not the same as the module name)
VBA Code:
Sub DefectSearchForm()
With UserDefectSearch
Sheets("Dashboard").Unprotect "1"
.StartUpPosition = 0
.Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
.Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
.Show
Sheets("Dashboard").Protect "1"
End With
End Sub
NOTE - I have also tried using ActiveSheet.Unprotect "1" and this did not work.
Please Help
Cheers