How do you get a macro not to go to or change a locked cell?

B

bxs02205

I have the cells locked, the sheet protected and have only "Select unlocked
cells" and "Format cells" checked. If I turn "Format cells" off, the macro
doesn't work. Below is the macro:
Selection.Interior.ColorIndex = 4
Selection.Font.ColorIndex = 1
ActiveCell.Offset(1, 0).Range("A1").Select

It changes the fill to green, the text to black, and move down one row.

Please help.........
 
T

Tom Hutchins

I'm not clear what you are trying to accomplish. Do you want your macro to be
able to change only an unlocked cell to green, then move down one cell if
that cell is also unlocked? If so, try this:

If ActiveCell.Locked = True Then Exit Sub
Selection.Interior.ColorIndex = 4
Selection.Font.ColorIndex = 1
If ActiveCell.Offset(1, 0).Locked = True Then Exit Sub
ActiveCell.Offset(1, 0).Select

Hope this helps,

Hutch
 

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