Hi I am trying to run some macros in a protected sheet.
I believe using the UserInterFaceOnly:=True method will allow this and i have it in my Workbook_Open macro.
But a simple operation of copying a relative formula does not work.
Setup code:
The simple following code will then work when sheet is unlocked but fails when locked on the FormulaR1C1 line.
It seems .Value works but .Formula doesn't.
Cell H16 should end up with the formula "=B3".
I'm open to solutions or better approaches.
Thanks you so much all!
I believe using the UserInterFaceOnly:=True method will allow this and i have it in my Workbook_Open macro.
But a simple operation of copying a relative formula does not work.
Setup code:
VBA Code:
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="abc", userinterfaceonly:=True
Next ws
End Sub
The simple following code will then work when sheet is unlocked but fails when locked on the FormulaR1C1 line.
It seems .Value works but .Formula doesn't.
Cell H16 should end up with the formula "=B3".
I'm open to solutions or better approaches.
VBA Code:
Sub PasteFormula()
Range("H15").Value = "=B2"
Range("H16").FormulaR1C1 = Range("H15").FormulaR1C1
End Sub