B
Ben in CA
Hi,
I'm having an issue with some code, that only started being a problem once I
protected the worksheet.
I have the following macro that clears some cells and checkboxes - tied to a
form button called Clear.
Sub Clear()
Application.ScreenUpdating = False
Columns("U:W").Clear ' Clear columns
Columns("U:W").NumberFormat = "$#,##0.00" ' Make Currencey format
Range("U1").Select ' Select a single cell to avoid confusion
For Each Shp In ActiveSheet.Shapes ' Clear Checkboxes
X = Shp.Type
If X = msoFormControl Then
If Shp.FormControlType = xlCheckBox Then
Shp.ControlFormat.Value = False
End If
End If
Next Shp
Application.ScreenUpdating = True
End Sub
Here's what I'm doing:
I select columns U, V, and W.
I right click, format cells, and uncheck Lock Cells on the protection tab.
I protect my worksheet.
The I can enter random values in these columns.
Then, I want to clear them - and I click clear. It clears them, and no errors.
But the next time I press clear, I get this error message:
Runtime Error '1004'
The cell or chart that you are trying to change is protected and therefore
read-only.
Any ideas why?
(And if I then unprotect the sheet, they show up as locked when I check
their properties - and yet I could change their contents when it was
protected.)
Thanks in advance,
Ben
I'm having an issue with some code, that only started being a problem once I
protected the worksheet.
I have the following macro that clears some cells and checkboxes - tied to a
form button called Clear.
Sub Clear()
Application.ScreenUpdating = False
Columns("U:W").Clear ' Clear columns
Columns("U:W").NumberFormat = "$#,##0.00" ' Make Currencey format
Range("U1").Select ' Select a single cell to avoid confusion
For Each Shp In ActiveSheet.Shapes ' Clear Checkboxes
X = Shp.Type
If X = msoFormControl Then
If Shp.FormControlType = xlCheckBox Then
Shp.ControlFormat.Value = False
End If
End If
Next Shp
Application.ScreenUpdating = True
End Sub
Here's what I'm doing:
I select columns U, V, and W.
I right click, format cells, and uncheck Lock Cells on the protection tab.
I protect my worksheet.
The I can enter random values in these columns.
Then, I want to clear them - and I click clear. It clears them, and no errors.
But the next time I press clear, I get this error message:
Runtime Error '1004'
The cell or chart that you are trying to change is protected and therefore
read-only.
Any ideas why?
(And if I then unprotect the sheet, they show up as locked when I check
their properties - and yet I could change their contents when it was
protected.)
Thanks in advance,
Ben