Pause vba for manual action in excel

jokkebal

New Member
Joined
Jun 26, 2014
Messages
18
I want to allow users to sort a protected worksheet. Apparently, this is not possible without unprotecting. This is the workaround I think about :
  • user launches macro (button, shortcut,...) that unprotects for, say 15 seconds.
  • user can now sort
  • vba reprotrects after the 15 seconds

In other words, VBA should not wait until something happens (filling of a cell,...), just re-protect when 15 seconds are over

How can I do this ?
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

ryansclev

Board Regular
Joined
Jul 29, 2014
Messages
79
The following subs should unprotect the sheet for 15 seconds and allow edits before protecting the sheet again.

Code:
Sub ProtectOnOff()
ActiveSheet.Unprotect Password:="Password"
Application.OnTime Now() + (TimeValue("00:00:15")), "ProtectSheet"
End Sub

Sub ProtectSheet()
ActiveSheet.Protect Password:="Password"
MsgBox "Worksheet Protected"
End Sub
 

jokkebal

New Member
Joined
Jun 26, 2014
Messages
18
This exactly does what I hoped for, plus the MsgBox as an extra. Many thanks !
 

Watch MrExcel Video

Forum statistics

Threads
1,099,685
Messages
5,470,132
Members
406,681
Latest member
sachinmasurkar

This Week's Hot Topics

Top