Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Unprotect from Forms Listbox

Using Excel 2000, I have a simple macro to hide or show a column
depending on the choice made from a list box (forms) control on the
worksheet:

Sub ModelSelect_Change()
On Error Resume Next
ActiveCell.Activate
ActiveSheet.Unprotect
If Range("ModelSelect").Value = 1 Then
'Hide it
Columns("E:E").Select
Selection.EntireColumn.Hidden = True
Else
'Show it
Columns("D:F").Select
Selection.EntireColumn.Hidden = False
End If
ActiveSheet.Protect
End Sub

However, the unprotect fails and Excel tells me "the cell or chart you
are trying to change is protected....", etc. and tells me to remove the
protection which is, of course, what the macro is attempting to do!
Where am I going wrong?
Cheers......Mike

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Unprotect from Forms Listbox

Hi

i get the same error message if the cell linked to the listbox is
protected - so unprotect the sheet first, choose this linked cell, choose
format / cells / protection, untick locked, then your code should work fine
(BTW not sure what activecell.activate actually achieves).

Cheers
JulieD

wrote in message
oups.com...
Using Excel 2000, I have a simple macro to hide or show a column
depending on the choice made from a list box (forms) control on the
worksheet:

Sub ModelSelect_Change()
On Error Resume Next
ActiveCell.Activate
ActiveSheet.Unprotect
If Range("ModelSelect").Value = 1 Then
'Hide it
Columns("E:E").Select
Selection.EntireColumn.Hidden = True
Else
'Show it
Columns("D:F").Select
Selection.EntireColumn.Hidden = False
End If
ActiveSheet.Protect
End Sub

However, the unprotect fails and Excel tells me "the cell or chart you
are trying to change is protected....", etc. and tells me to remove the
protection which is, of course, what the macro is attempting to do!
Where am I going wrong?
Cheers......Mike



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default Unprotect from Forms Listbox

"JulieD" skrev i melding
...

(BTW not sure what activecell.activate actually achieves).


Hi Julie

It's generally useful for Excel 97 where ActiveX controls on worksheets tend
to take focus, resulting in no selection, no active cell and a few less
logical side effects. (Not saying that one should write 97 compatible code
as a rule, but activecell.activate doesn't limit or harm anything.)

Best wishes Harald


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Unprotect from Forms Listbox

Hi Harald

thanks for the clarification.

Cheers
JulieD

"Harald Staff" wrote in message
...
"JulieD" skrev i melding
...

(BTW not sure what activecell.activate actually achieves).


Hi Julie

It's generally useful for Excel 97 where ActiveX controls on worksheets
tend
to take focus, resulting in no selection, no active cell and a few less
logical side effects. (Not saying that one should write 97 compatible code
as a rule, but activecell.activate doesn't limit or harm anything.)

Best wishes Harald




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Unprotect from Forms Listbox

Thanks a lot, Julie, it works fine now. Something that simple has
caused me so much grief today!
Cheers....Mike



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Unprotect from Forms Listbox

Thanks a lot, Julie, it works fine now. That little problem caused me
so much grief today!
Cheers....Mike

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
MS Forms ListBox no longer accessible??? bryan baker Excel Programming 0 September 17th 04 10:45 PM
MultiSelect Listbox (Forms Toolbar) Ryan Holmes Excel Programming 1 July 27th 04 01:16 AM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM
Strange (forms) ListBox behavior steve Excel Programming 0 July 23rd 03 05:46 PM


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