Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Unpredictable results with Macro and VBA

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?


--
vze2mss6
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Unpredictable results with Macro and VBA

Hi.

don't bother I figured it out. Thanks so much.
--
vze2mss6


"joesf16" wrote:

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?


--
vze2mss6

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking workbooks unpredictable Johnathan New Users to Excel 1 May 30th 09 03:00 AM
hyperlink unpredictable merlin New Users to Excel 2 May 28th 09 12:59 AM
cell format unpredictable willy Excel Discussion (Misc queries) 5 November 12th 08 09:00 PM
unpredictable combobox behavior Jacob Excel Programming 0 November 9th 06 12:44 PM
WorkbookOpen event unpredictable JT[_5_] Excel Programming 0 September 21st 04 12:47 PM


All times are GMT +1. The time now is 10:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"