Mr_Adams
Active Member
- Joined
- Oct 7, 2002
- Messages
- 475
I use this code to replace the contents of any unprotected cell with a "0"
<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> UserForm_Activate()
DoEvents
<SPAN style="color:#00007F">Set</SPAN> WorkRange = ActiveSheet.UsedRange
<SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> Cell <SPAN style="color:#00007F">In</SPAN> WorkRange
<SPAN style="color:#00007F">If</SPAN> Cell.Locked = <SPAN style="color:#00007F">False</SPAN> <SPAN style="color:#00007F">Then</SPAN> Cell.Value = "0"
<SPAN style="color:#00007F">Next</SPAN> Cell
Unload UserForm1
ActiveWorkbook.Save
Range("C5").Select
MsgBox "The sheet has been cleared " & Chr(13) & _
"and saved" & Chr(13) & Chr(13) & _
"Click OK to continue", vbInformation + vbOKOnly, "Clearing Complete"
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
<SPAN style="color:#007F00">
Would it be possible to modify the code to do the following?
Any unprotected cell in Column A or Cloumn B = VBNullstring
Any unprotected cell in Column C = "No Changes"
Any unprotected cell in Column D or Cloumn E = "0"
<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> UserForm_Activate()
DoEvents
<SPAN style="color:#00007F">Set</SPAN> WorkRange = ActiveSheet.UsedRange
<SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> Cell <SPAN style="color:#00007F">In</SPAN> WorkRange
<SPAN style="color:#00007F">If</SPAN> Cell.Locked = <SPAN style="color:#00007F">False</SPAN> <SPAN style="color:#00007F">Then</SPAN> Cell.Value = "0"
<SPAN style="color:#00007F">Next</SPAN> Cell
Unload UserForm1
ActiveWorkbook.Save
Range("C5").Select
MsgBox "The sheet has been cleared " & Chr(13) & _
"and saved" & Chr(13) & Chr(13) & _
"Click OK to continue", vbInformation + vbOKOnly, "Clearing Complete"
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
<SPAN style="color:#007F00">
Would it be possible to modify the code to do the following?
Any unprotected cell in Column A or Cloumn B = VBNullstring
Any unprotected cell in Column C = "No Changes"
Any unprotected cell in Column D or Cloumn E = "0"