Unpredictable results with Macro and VBA

G

Guest

Hi.

Excel 2003. I'm seeing some buggy results.

Trying to create form where people cannot change data after they have
entered it. I also have comment boxes with pictures inside. These comment
boxes I need to have locked down also so that people cannot move the pictures
around.

1. Starting with new workbook I unlocked all cells under format cells,
protection.

2. I started with unprotected workbook and sheet.

3. I then added a comment box.

4. I then entered the following code in a module.

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Protect Contents:=False
Target.Locked = True
ActiveSheet.Protect Contents:=True
End Sub


5. It allowed me to enter into cells, but I could not make changes afterward.

Then:

I wanted the boss to be able to make changes in cells if necessary, so I
created a macro in excel. I first placed the cursor in the cell I wanted to
change then the macro used the mouse to go to tools, protection, and
unprotect sheet.

Then:

The boss would have to re-protect sheet to not allow employees to make
changes again. So I created another macro with the mouse going to tools,
protection, unprotect sheet then back to tools, protection, protect sheet.


This worked except there are always a few cells which will not allow people
to type into them even though they were blank. So this is my real concern.
Even after the sheet should allow typing it does not. This only occurs, as I
said, in only about 2% of the cells.

I have a hunch that there is a conflict between the code I have entered and
the macros I am trying to run. Either that or I do not truly understand
protect and unprotect sheets.

Can someone help?
 

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