Error when saving whilst a shared workbook

Pauljj

Well-known Member
Joined
Mar 28, 2004
Messages
2,047
I am getting a runtime error 1004, application defined or object defined error when I save this file. This only happens once I switch it onto be a 'shared workbook'

I have the following before save macro

Private Sub WORKBOOK_BEFORESAVE(ByVal SAVEASUI As Boolean, Cancel As Boolean)

If Sheets("Working Stats").Range("P2") > 5 Then

MsgBox "There is an error on row number " & Range("P2") & " You must enter a location. This file has not been saved"

If SAVEASUI = False Then
Cancel = True

End If

End If

With Worksheets("Weekly Figures")
.EnableSelection = xlNoRestrictions
.Protect Contents:=True, UserInterfaceOnly:=True
End With

End Sub


I also have the following worksheet code

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
If Target.Column = 2 Then
Range(Target, Target.Offset(0, 8)).Interior.ColorIndex = 6
End If
End Sub

Can anyone see what of these might be leading to my error please ?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
thanks Glenn, I have commented out the protection part of the code

Many thanks for your reply
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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