Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Excel 2003/7 VBA (Un) Protection not working

I use Excel2007 and save in 2003-file format for compatibility. I
wrote VBA code to create an in-cell drop-down list based on a certain
value in cell B6.

As I protect the spreadsheet, the drop-down validation list doesn't
work. I added code to unprotect and then protect afterwards again
which worked 100%. My company installed the latest updates on Vista
(not Office2007 as far as I know) and now the PROTECT error code gives
an error. Any ideas on how to fix this? My code below:

------------------------------------------------------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$B$7" Then
'Set the validation box property for cell B7 to the correct range
depending on B6
ActiveSheet.Unprotect ---seems to work fine
With ActiveCell
.Validation.Delete --- blank current range name/formula

'--- test value and select appropriate range of category values

If Range("B6").Value = "Domestic" Then
.Validation.Add xlValidateList, , , "=" & "EL_DOM_Cats"
End If
End With

ActiveSheet.Protect ----- ERROR saying Protect method failed.

End If

End Sub
--------------------------------------------------------------------------------------------------------------------------
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6,582
Default Excel 2003/7 VBA (Un) Protection not working

Perhaps you could use Debra's technique for dependent validation lists, and
avoid having to unprotect and reprotect:

http://contextures.com/xlDataVal02.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Ferdie" wrote in message
...
I use Excel2007 and save in 2003-file format for compatibility. I
wrote VBA code to create an in-cell drop-down list based on a certain
value in cell B6.

As I protect the spreadsheet, the drop-down validation list doesn't
work. I added code to unprotect and then protect afterwards again
which worked 100%. My company installed the latest updates on Vista
(not Office2007 as far as I know) and now the PROTECT error code gives
an error. Any ideas on how to fix this? My code below:

------------------------------------------------------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$B$7" Then
'Set the validation box property for cell B7 to the correct range
depending on B6
ActiveSheet.Unprotect ---seems to work fine
With ActiveCell
.Validation.Delete --- blank current range name/formula

'--- test value and select appropriate range of category values

If Range("B6").Value = "Domestic" Then
.Validation.Add xlValidateList, , , "=" & "EL_DOM_Cats"
End If
End With

ActiveSheet.Protect ----- ERROR saying Protect method failed.

End If

End Sub
--------------------------------------------------------------------------------------------------------------------------


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
Excel 2003: Protection oceanmist Excel Discussion (Misc queries) 1 June 19th 07 09:26 PM
Excel 2003 Sheet Protection Issues Eric Svatik Excel Discussion (Misc queries) 0 May 7th 07 04:36 PM
Excel 2003: Protection oceanmist Excel Discussion (Misc queries) 1 September 20th 06 10:36 PM
protection in excel 2003 rameshpm Excel Discussion (Misc queries) 1 June 27th 06 01:04 PM
Just upgraded to excel 2003 and protection is a problem Roger Excel Worksheet Functions 0 February 20th 06 07:38 PM


All times are GMT +1. The time now is 06:23 PM.

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

About Us

"It's about Microsoft Excel"