rochytall2000
New Member
- Joined
- Sep 15, 2006
- Messages
- 24
- Office Version
-
- 365
- 2019
hi all, i need to be able to let the user copy and paste cells that are protected, how can I do this using VBA. I have created a macro to look at the VBA created when protecting spreadsheet from Tools menu but I can't replicate if using VBA. help is always appreciated, here's the code
If answer = vbYes Then
ActiveSheet.Unprotect "password"
Range("F7").Select
ActiveCell.FormulaR1C1 = Application.UserName & " " & Now
Cells.Select
Selection.Locked = True
Selection.FormulaHidden = True
Range("A1").Select
' Switch Highlighting
Range("F7").Select
Selection.Interior.ColorIndex = xlNone
Selection.Font.Bold = False
Range("F7").Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlGray25
.PatternColorIndex = 0
End With
With Selection.Font
.Bold = True
.Italic = False
End With
ActiveSheet.Shapes("Button 1").Visible = False
ActiveSheet.Protect "password", DrawingObjects:=True, Contents:=True, Scenarios:=True
'ActiveSheet.EnableSelection = xlUnlockedCells
Application.ScreenUpdating = False
'Lock Accounts Tab
Sheets("Accounts").Select
ActiveSheet.Unprotect "password"
Cells.Select
Selection.Locked = True
Range("A1").Select
ActiveSheet.Protect "password", DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
Application.ScreenUpdating = True
MsgBox "Template Locked"
End If
Thanks in advance
nagartath
If answer = vbYes Then
ActiveSheet.Unprotect "password"
Range("F7").Select
ActiveCell.FormulaR1C1 = Application.UserName & " " & Now
Cells.Select
Selection.Locked = True
Selection.FormulaHidden = True
Range("A1").Select
' Switch Highlighting
Range("F7").Select
Selection.Interior.ColorIndex = xlNone
Selection.Font.Bold = False
Range("F7").Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlGray25
.PatternColorIndex = 0
End With
With Selection.Font
.Bold = True
.Italic = False
End With
ActiveSheet.Shapes("Button 1").Visible = False
ActiveSheet.Protect "password", DrawingObjects:=True, Contents:=True, Scenarios:=True
'ActiveSheet.EnableSelection = xlUnlockedCells
Application.ScreenUpdating = False
'Lock Accounts Tab
Sheets("Accounts").Select
ActiveSheet.Unprotect "password"
Cells.Select
Selection.Locked = True
Range("A1").Select
ActiveSheet.Protect "password", DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
Application.ScreenUpdating = True
MsgBox "Template Locked"
End If
Thanks in advance
nagartath