Hey guys! Can someone please help me with a macro I'm having issues with. I've created a macro that will reformat a cell in a protected sheet to it's original formatting, however it's only working in the cells that I initially recorded the macro in. I need it to work anywhere on the sheet when necessary. I have been experimenting with the range values to try and get this to work, but it's been to no avail. Can someone please help. Here is the current VBA code:
Sub ReformatCell()
'
' ReformatCell Macro
' This macro reformats a cell to its original formatting
'
' Keyboard Shortcut: Ctrl+y
'
Range("C20:d20").Select
Sheets("DTP Audit Checklist").Select
ActiveSheet.Unprotect
Range("C22:G22").Select
Selection.Copy
Range("C20:d20").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Selection.ClearContents
Sheets("DTP Audit Checklist").Select
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False
End Sub
The cells I am trying to target are c20:d20 through c84:d84 and then ag20:ai20 through ag91:ai91. Please let me know if I need to clarify anything, but I would appreciate any help you can offer. Thank you so much!
Sub ReformatCell()
'
' ReformatCell Macro
' This macro reformats a cell to its original formatting
'
' Keyboard Shortcut: Ctrl+y
'
Range("C20:d20").Select
Sheets("DTP Audit Checklist").Select
ActiveSheet.Unprotect
Range("C22:G22").Select
Selection.Copy
Range("C20:d20").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Selection.ClearContents
Sheets("DTP Audit Checklist").Select
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False
End Sub
The cells I am trying to target are c20:d20 through c84:d84 and then ag20:ai20 through ag91:ai91. Please let me know if I need to clarify anything, but I would appreciate any help you can offer. Thank you so much!