cocopops2001
Board Regular
- Joined
- Apr 18, 2011
- Messages
- 112
Dear All,
Two problems, one may be simple the other not so simple.
I have a workbook which is essentially a MENU workbook that I do not want anyone to change any values, formulas, formatting, colours etc.
The first problem is that I have buttons along the top of each page with a 'template' underneath. I want users to be able to push the buttons without editing the important part of the sheet I am using the following code in a seperate module:
[/vba]
Sub Unprotect()
ActiveSheet.Protect
ActiveSheet.Range("A11:N70").Locked = True
End Sub
[/vba]
The module is called using this peice of code in the this workbook section.
[/vba]
Private Sub Worksheet_Select()
Unprotect
End Sub
[/vba]
When I run it in the VBA editor it says 'runtime error 1004' unable to set the locked property of the range class. Any ideas?
My second problem is that when I copy these 'templates' into a new workbook the cell references still refer to the original MENU workbook ie ='[menu.xls]Cover Sheet'!$H$51 when i want it to refer to the cover sheet in the new work book.
I am copying the sheets using:
[/vba]
Sub sheetcopy()
ActiveSheet.Range("a11:n70").Copy
'subroutine to open select a workbook in which to place the calc sheet(module6)
OpenCalc
Worksheets.Add after:=Worksheets(Worksheets.Count)
Worksheets(Worksheets.Count).Range("a1").PasteSpecial
Application.CutCopyMode = False
End Sub
[/vba]
the open calc module is:
[/vba]
Sub OpenCalc()
Dim fn
fn = Application.GetOpenFilename 'can add parameters. See help for details.
If fn = False Then
MsgBox "Nothing Chosen"
Else
MsgBox "You chose " & fn
Workbooks.Open fn
End If
End Sub
[/vba]
Any help on this would be great.
Thanks.
Two problems, one may be simple the other not so simple.
I have a workbook which is essentially a MENU workbook that I do not want anyone to change any values, formulas, formatting, colours etc.
The first problem is that I have buttons along the top of each page with a 'template' underneath. I want users to be able to push the buttons without editing the important part of the sheet I am using the following code in a seperate module:
[/vba]
Sub Unprotect()
ActiveSheet.Protect
ActiveSheet.Range("A11:N70").Locked = True
End Sub
[/vba]
The module is called using this peice of code in the this workbook section.
[/vba]
Private Sub Worksheet_Select()
Unprotect
End Sub
[/vba]
When I run it in the VBA editor it says 'runtime error 1004' unable to set the locked property of the range class. Any ideas?
My second problem is that when I copy these 'templates' into a new workbook the cell references still refer to the original MENU workbook ie ='[menu.xls]Cover Sheet'!$H$51 when i want it to refer to the cover sheet in the new work book.
I am copying the sheets using:
[/vba]
Sub sheetcopy()
ActiveSheet.Range("a11:n70").Copy
'subroutine to open select a workbook in which to place the calc sheet(module6)
OpenCalc
Worksheets.Add after:=Worksheets(Worksheets.Count)
Worksheets(Worksheets.Count).Range("a1").PasteSpecial
Application.CutCopyMode = False
End Sub
[/vba]
the open calc module is:
[/vba]
Sub OpenCalc()
Dim fn
fn = Application.GetOpenFilename 'can add parameters. See help for details.
If fn = False Then
MsgBox "Nothing Chosen"
Else
MsgBox "You chose " & fn
Workbooks.Open fn
End If
End Sub
[/vba]
Any help on this would be great.
Thanks.