Oct 27 2021 08:04 AM
I have code that clears changes the color index of a cell. When I execute the code on a Workbook that I just opened and select the sheet I get the 1004 error on the first range statement below. Does anyone have an idea why I am getting this?
Worksheets("Measurement Form").Activate
'
'
'Resets "Values Changed" Indicator to White Font or Black Font
Range("J4").Font.ColorIndex = 2
Range("B7").Font.ColorIndex = 1
Oct 27 2021 08:10 AM
Has the Measurement Form worksheet been protected?
Oct 27 2021 08:13 AM
Oct 27 2021 08:33 AM
SolutionBy default, cells on a protected sheet cannot be formatted.
One solution is tick the check box 'Format Cells' in the 'Protect Sheet' dialog when you protect the sheet.
Another is to temporarily unprotect the sheet:
...
ActiveSheet.Unprotect Password:="secret"
Range("J4").Font.ColorIndex = 2
Range("B7").Font.ColorIndex = 1
ActiveSheet.Protect Password:="secret"
Oct 27 2021 08:56 AM
Oct 27 2021 08:33 AM
SolutionBy default, cells on a protected sheet cannot be formatted.
One solution is tick the check box 'Format Cells' in the 'Protect Sheet' dialog when you protect the sheet.
Another is to temporarily unprotect the sheet:
...
ActiveSheet.Unprotect Password:="secret"
Range("J4").Font.ColorIndex = 2
Range("B7").Font.ColorIndex = 1
ActiveSheet.Protect Password:="secret"