ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Shared Workbook (https://www.excelbanter.com/excel-programming/421520-shared-workbook.html)

John Pierce

Shared Workbook
 
What is it about this little bit of code that makes it give Error 1004
when the Workbook is shared but it works fine when the wb is not
shared?

Private Sub SaveRecord()

ActiveWorkbook.Save
LocateFirstEmptyRow
On Error GoTo ErrorHandler

ActiveSheet.Unprotect

With ActiveCell
.Value = cmbIndividuals
.Offset(0, 1).Value = cmbManagers
.Offset(0, 2).Value = cmbTeams
End With

ErrorHandler:
ActiveWorkbook.Save
LocateFirstEmptyRow

End Sub

Public Sub LocateFirstEmptyRow()
Range("B65536").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Range("A1").Activate
End Sub

Dave Peterson

Shared Workbook
 
You can't change protection of a worksheet in a shared workbook.

There are lots of things that are unavailable in shared workbooks. Excel's help
(not VBA) has a list.

John Pierce wrote:

What is it about this little bit of code that makes it give Error 1004
when the Workbook is shared but it works fine when the wb is not
shared?

Private Sub SaveRecord()

ActiveWorkbook.Save
LocateFirstEmptyRow
On Error GoTo ErrorHandler

ActiveSheet.Unprotect

With ActiveCell
.Value = cmbIndividuals
.Offset(0, 1).Value = cmbManagers
.Offset(0, 2).Value = cmbTeams
End With

ErrorHandler:
ActiveWorkbook.Save
LocateFirstEmptyRow

End Sub

Public Sub LocateFirstEmptyRow()
Range("B65536").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Range("A1").Activate
End Sub


--

Dave Peterson


All times are GMT +1. The time now is 09:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com