Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Using Worksheet_change module in protected workbook.

I have a Worksheet_change module on each sheet tab in a workbook that links
the sheet tab name to a specific cell on the worksheet. Here is the simple
code:

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Name = Range("B2").Value
End Sub

The problem is that when the workbook is protected, users get this error
message when attempting to enter data into any of their "unprotected"
regions: "application-defined or object-defined error". The Debug button
goes to the Worksheet_change code--- which confuses me because they are not
entering into cell B2 (it is protected). I'll admit this code is new to me,
but what am I missing?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Using Worksheet_change module in protected workbook.

That macro fires whenever any change is made to any cell in the entire sheet
and that is what is causing that error. If you want the code within that
macro (the sheet name code) to execute only when B2 is changed, you must
enter a line similar to the following before your sheet name code:
"If Not Intersect(Target, Range("B2")) is Nothing Then _" without the
quotes. HTH Otto
"JDaywalt" wrote in message
...
I have a Worksheet_change module on each sheet tab in a workbook that links
the sheet tab name to a specific cell on the worksheet. Here is the
simple
code:

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Name = Range("B2").Value
End Sub

The problem is that when the workbook is protected, users get this error
message when attempting to enter data into any of their "unprotected"
regions: "application-defined or object-defined error". The Debug button
goes to the Worksheet_change code--- which confuses me because they are
not
entering into cell B2 (it is protected). I'll admit this code is new to
me,
but what am I missing?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Using Worksheet_change module in protected workbook.

Absolutely perfect! (Just had to remember to also add the "Else ... End If"
at the bottom of my sheet code!!)

Thanks for your help!

"Otto Moehrbach" wrote:

That macro fires whenever any change is made to any cell in the entire sheet
and that is what is causing that error. If you want the code within that
macro (the sheet name code) to execute only when B2 is changed, you must
enter a line similar to the following before your sheet name code:
"If Not Intersect(Target, Range("B2")) is Nothing Then _" without the
quotes. HTH Otto
"JDaywalt" wrote in message
...
I have a Worksheet_change module on each sheet tab in a workbook that links
the sheet tab name to a specific cell on the worksheet. Here is the
simple
code:

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Name = Range("B2").Value
End Sub

The problem is that when the workbook is protected, users get this error
message when attempting to enter data into any of their "unprotected"
regions: "application-defined or object-defined error". The Debug button
goes to the Worksheet_change code--- which confuses me because they are
not
entering into cell B2 (it is protected). I'll admit this code is new to
me,
but what am I missing?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Using Worksheet_change module in protected workbook.

The code line I sent you doesn't require an Else or End If. The space and
underline character at the end of the line tells Excel that those "2" lines
are to be taken as one line. HTH Otto
"JDaywalt" wrote in message
...
Absolutely perfect! (Just had to remember to also add the "Else ... End
If"
at the bottom of my sheet code!!)

Thanks for your help!

"Otto Moehrbach" wrote:

That macro fires whenever any change is made to any cell in the entire
sheet
and that is what is causing that error. If you want the code within that
macro (the sheet name code) to execute only when B2 is changed, you must
enter a line similar to the following before your sheet name code:
"If Not Intersect(Target, Range("B2")) is Nothing Then _" without the
quotes. HTH Otto
"JDaywalt" wrote in message
...
I have a Worksheet_change module on each sheet tab in a workbook that
links
the sheet tab name to a specific cell on the worksheet. Here is the
simple
code:

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Name = Range("B2").Value
End Sub

The problem is that when the workbook is protected, users get this
error
message when attempting to enter data into any of their "unprotected"
regions: "application-defined or object-defined error". The Debug
button
goes to the Worksheet_change code--- which confuses me because they are
not
entering into cell B2 (it is protected). I'll admit this code is new
to
me,
but what am I missing?






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
Can Worksheet_Change run from separate module? Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 7 October 1st 09 09:07 PM
Worksheet_Change stopped working after sheet is protected [email protected] Excel Programming 1 December 1st 06 04:30 PM
Worksheet_Change stoped working after sheet is protected [email protected] Excel Programming 5 November 30th 06 09:46 AM
Run worksheet module code from workbook module? keithb Excel Programming 1 August 14th 05 04:04 AM
Import module in protected project? [email protected] Excel Programming 0 January 5th 05 07:38 PM


All times are GMT +1. The time now is 05:46 PM.

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"