Macros Stopped Working since Shared Workbook

JEB85

Board Regular
Joined
Aug 13, 2010
Messages
238
Hi Guys,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
I’ve just shared a workbook that I’ve created – problem is some of my macros have stopped working. When I run one of the macros, for example, I get a ‘Unprotect method of worksheet class failed’ message. I also think there’s an issue with the Show All Data aspect of the code. I’ve never had to share a workbook before so haven’t got a clue what changes I need to make.<o:p></o:p>
<o:p> </o:p>
Here’s the code;<o:p></o:p>
<o:p> </o:p>
Private Sub Period1Exceptions()<o:p></o:p>
'<o:p></o:p>
' Period1Exceptions Macro<o:p></o:p>
'<o:p></o:p>
<o:p> </o:p>
'<o:p></o:p>
Application.ScreenUpdating = False<o:p></o:p>
Application.Calculation = xlCalculationManual<o:p></o:p>
Sheet2.Select<o:p></o:p>
With ActiveSheet<o:p></o:p>
.Unprotect Password:="xxx"<o:p></o:p>
End With<o:p></o:p>
ActiveSheet.ShowAllData<o:p></o:p>
Range("B6:K306").Select<o:p></o:p>
Selection.Clear<o:p></o:p>
Sheet1.Select<o:p></o:p>
With ActiveSheet<o:p></o:p>
.Unprotect Password:="xxx"<o:p></o:p>
End With<o:p></o:p>
Range("B6:K306").Select<o:p></o:p>
Selection.Copy<o:p></o:p>
Sheet2.Select<o:p></o:p>
Range("B6").Select<o:p></o:p>
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _<o:p></o:p>
:=False, Transpose:=False<o:p></o:p>
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _<o:p></o:p>
SkipBlanks:=False, Transpose:=False<o:p></o:p>
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _<o:p></o:p>
SkipBlanks:=False, Transpose:=False<o:p></o:p>
Application.CutCopyMode = False<o:p></o:p>
Range("F6").Select<o:p></o:p>
Selection.FormulaR1C1 = "Last Supervision"<o:p></o:p>
Range("M7").Select<o:p></o:p>
Selection.FormulaHidden = True<o:p></o:p>
Range("B6").Select<o:p></o:p>
Range("B6:K306").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _<o:p></o:p>
Range("M6:M7"), Unique:=False<o:p></o:p>
Range("B6:K307").Select<o:p></o:p>
Selection.Locked = True<o:p></o:p>
Cells(2, 8).Value = Format(Now, "hh:mmampm dd/mm/yyyy")<o:p></o:p>
Sheet1.Select<o:p></o:p>
Range("A1").Select<o:p></o:p>
With ActiveSheet<o:p></o:p>
.Protect Password:="xxx"<o:p></o:p>
End With<o:p></o:p>
Sheet2.Select<o:p></o:p>
Range("A1").Select<o:p></o:p>
With ActiveSheet<o:p></o:p>
.Protect Password:="xxx"<o:p></o:p>
End With<o:p></o:p>
Application.Calculation = xlCalculationAutomatic<o:p></o:p>
Application.ScreenUpdating = True<o:p></o:p>
End Sub<o:p></o:p>
<o:p> </o:p>
Any help would be appreciated.<o:p></o:p>
<o:p> </o:p>
Thanks<o:p></o:p>
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi,

Unfortunatly you cannot programmatically unprotect a shared workbook.

You could always Unshare and Unprotect the sheet manually first, do the changes and then protect it again.
 
Upvote 0
Better yet, don't share the workbook. If you have to, make sure you keep frequent backups.
 
Upvote 0
Thanks James/rorya.

I'm just gonna create some huge array formulas to extract the exceptions as opposed to advanced filter macros lol
 
Upvote 0

Forum statistics

Threads
1,224,565
Messages
6,179,549
Members
452,927
Latest member
rows and columns

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