Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Lock/Unlock problem

By using the two macros below, which works fine, I would like to toggle the
lock/unlock
function with one button only instead of the two which I use at present.
Sadly I can't get it to work, any ideas gratefully received.
Jim

Sub UnlockSheet()
On Error Resume Next
With ActiveSheet
.Unprotect
End With
On Error GoTo 0
End Sub

Sub LockSheet()
On Error Resume Next
With ActiveSheet
.Protect
End With
On Error GoTo 0
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Lock/Unlock problem

Hi Jim,

you can try this
Sub ToggleSheet()
On Error Resume Next
With ActiveSheet
If .ProtectContents = True Then
.Unprotect
Else
.Protect
End If
End With
On Error GoTo 0
End Sub

HTH
Frank

Jim wrote:
By using the two macros below, which works fine, I would like to
toggle the lock/unlock
function with one button only instead of the two which I use at
present. Sadly I can't get it to work, any ideas gratefully received.
Jim

Sub UnlockSheet()
On Error Resume Next
With ActiveSheet
.Unprotect
End With
On Error GoTo 0
End Sub

Sub LockSheet()
On Error Resume Next
With ActiveSheet
.Protect
End With
On Error GoTo 0
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Lock/Unlock problem

Hi Frank
Brilliant, just what I needed. many thanks
Jim

"Frank Kabel" wrote in message
...
Hi Jim,

you can try this
Sub ToggleSheet()
On Error Resume Next
With ActiveSheet
If .ProtectContents = True Then
.Unprotect
Else
.Protect
End If
End With
On Error GoTo 0
End Sub

HTH
Frank

Jim wrote:
By using the two macros below, which works fine, I would like to
toggle the lock/unlock
function with one button only instead of the two which I use at
present. Sadly I can't get it to work, any ideas gratefully received.
Jim

Sub UnlockSheet()
On Error Resume Next
With ActiveSheet
.Unprotect
End With
On Error GoTo 0
End Sub

Sub LockSheet()
On Error Resume Next
With ActiveSheet
.Protect
End With
On Error GoTo 0
End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Lock/Unlock problem

Hi Jim

you're welcome
Frank

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
Lock Unlock Cell Protection Mike Josephson Excel Worksheet Functions 3 July 17th 09 10:06 PM
Lock/Unlock cells BFife Excel Worksheet Functions 2 October 25th 06 03:20 PM
Problem with File lock/unlock Slim Excel Discussion (Misc queries) 2 March 25th 05 09:45 AM
Lock and Unlock cells using VBA Peter Excel Discussion (Misc queries) 1 January 29th 05 02:00 PM
Lock / Unlock Cell Terence Excel Programming 1 September 30th 03 02:44 PM


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

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"