Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 318
Default macro does not work if form protected

Hello
Excel 2002 I created a form with a drop down list as follows : Select
Country, US, CA
Then I created this macro
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = Range("B36").Address Then
If Target = "US " Then
Range("C49") = "State"
Else
If Target.Address = Range("B36").Address Then
If Target = "Canada " Then
Range("C49") = "Province"
End If

End If
End If
End If
End Sub

IF the form is not protected the macro works but once I protected the form
the macro does not work. (Cell C49 is locked)
Thanks in advance

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,718
Default macro does not work if form protected

Your macro should unprotect and reprotect the worksheet.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$36" Then
ActiveSheet.Unprotect "pass"
If Target.Value = "US" Then
Range("C49").Value = "State"
Else
Range("C49").Value = "Province"
End If
ActiveSheet.Protect "pass"
End If
End Sub

--
Jim
"Wanna Learn" wrote in message
...
| Hello
| Excel 2002 I created a form with a drop down list as follows : Select
| Country, US, CA
| Then I created this macro
| Private Sub Worksheet_Change(ByVal Target As Range)
|
| If Target.Address = Range("B36").Address Then
| If Target = "US " Then
| Range("C49") = "State"
| Else
| If Target.Address = Range("B36").Address Then
| If Target = "Canada " Then
| Range("C49") = "Province"
| End If
|
| End If
| End If
| End If
| End Sub
|
| IF the form is not protected the macro works but once I protected the form
| the macro does not work. (Cell C49 is locked)
| Thanks in advance
|


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default macro does not work if form protected

Either unlock that C49 cell--or add code that unprotects the sheet, does the
work, then reprotects the sheet.



Wanna Learn wrote:

Hello
Excel 2002 I created a form with a drop down list as follows : Select
Country, US, CA
Then I created this macro
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = Range("B36").Address Then
If Target = "US " Then
Range("C49") = "State"
Else
If Target.Address = Range("B36").Address Then
If Target = "Canada " Then
Range("C49") = "Province"
End If

End If
End If
End If
End Sub

IF the form is not protected the macro works but once I protected the form
the macro does not work. (Cell C49 is locked)
Thanks in advance


--

Dave Peterson
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
Add tab access to check boxes in a protected Excel sheet form. Suebriquet Excel Discussion (Misc queries) 0 July 25th 07 07:12 PM
control form macros and protected sheets Greyson Excel Discussion (Misc queries) 1 November 4th 06 02:33 AM
Protected work shet Stuart Carnachan Excel Discussion (Misc queries) 2 August 30th 06 04:16 PM
excel -can I use a text box as unprotected box in protected form. Big Geoff Excel Discussion (Misc queries) 1 June 11th 06 05:58 PM
protected form Debbie Excel Discussion (Misc queries) 3 July 26th 05 05:46 PM


All times are GMT +1. The time now is 11:52 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"