put zero value to unprotected cells

G

GUS

How can i put with a macro the zero(0.00) value to all cells that are
unprotected .

The range that i am working and it is protected is
c4 to m102
not all cells of course are protected
 
T

Tom Ogilvy

if ActiveSheet.ProtectContents then
ActiveSheet.Protect UserInterfaceOnly:=True
End if
for each cell in range("C4:M102")
if cell.locked = False then
cell.Value = 0
cell.Numberformat = "0.00"
end if
Next

if using xl2002, and the sheet is protected and has a password, you will
need to supply the password as well.
 
G

Gord Dibben

GUS

Selection.NumberFormat = "0.00" should read..

cell.NumberFormat = "0.00"

To prevent losing formatting on Locked cells.

Gord
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top