Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MWS MWS is offline
external usenet poster
 
Posts: 53
Default Aborting Execution Before Error Message

Hello, My goal is to have code to, upon activating a sheet, to unprotect the
sheet if the user imputs the correct password and then complete some other
tasks (the "other" portion I have figured out. The code is as follows:

Private Sub Worksheet_Activate()
If ActiveSheet.Protect = False Then
ActiveSheet.Unprotect
Rows("2:5000").Select
Selection.EntireRow.Hidden = False
Range("A1:L5004").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("A1").Select
End If

The issue is, if the user does not value the correct password, they receive
an error. My question is: What is the code to be added so if the user inputs
the correct password the code continues and if the incorrect password is
valued the execution aborts and the error meesage is not presented (I realize
the user just needs to click "end" when then error is received, but I'd like
to have a cleaner process).

Any and All Help Is Appreciated - Thank You
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Aborting Execution Before Error Message

Hi MWS,

Try:

'=============
Private Sub Worksheet_Activate()
On Error GoTo XIT:
ActiveSheet.Unprotect
On Error GoTo 0
Rows("2:5000").Select
Selection.EntireRow.Hidden = False
Range("A1:L5004").Select
Selection.Sort Key1:=Range("A2"), _
Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("A1").Select
Exit Sub

XIT:
MsgBox "Your password was not recognised"""

End Sub
'<<=============


---
Regards,
Norman



"MWS" wrote in message
...
Hello, My goal is to have code to, upon activating a sheet, to unprotect
the
sheet if the user imputs the correct password and then complete some other
tasks (the "other" portion I have figured out. The code is as follows:

Private Sub Worksheet_Activate()
If ActiveSheet.Protect = False Then
ActiveSheet.Unprotect
Rows("2:5000").Select
Selection.EntireRow.Hidden = False
Range("A1:L5004").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("A1").Select
End If

The issue is, if the user does not value the correct password, they
receive
an error. My question is: What is the code to be added so if the user
inputs
the correct password the code continues and if the incorrect password is
valued the execution aborts and the error meesage is not presented (I
realize
the user just needs to click "end" when then error is received, but I'd
like
to have a cleaner process).

Any and All Help Is Appreciated - Thank You



  #3   Report Post  
Posted to microsoft.public.excel.programming
MWS MWS is offline
external usenet poster
 
Posts: 53
Default Aborting Execution Before Error Message

Norman, Thank You, this addresses the inputting of an incorrect password.

A point I failed to mention and perhaps you can help with is, if the user
chooses "cancel" instead of inputting a password at the prompt an error
message is displayed. Can this too be avoided with code and if so, what would
it be?

Thanks Again - I Appreciate Your Help

"Norman Jones" wrote:

Hi MWS,

Try:

'=============
Private Sub Worksheet_Activate()
On Error GoTo XIT:
ActiveSheet.Unprotect
On Error GoTo 0
Rows("2:5000").Select
Selection.EntireRow.Hidden = False
Range("A1:L5004").Select
Selection.Sort Key1:=Range("A2"), _
Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("A1").Select
Exit Sub

XIT:
MsgBox "Your password was not recognised"""

End Sub
'<<=============


---
Regards,
Norman



"MWS" wrote in message
...
Hello, My goal is to have code to, upon activating a sheet, to unprotect
the
sheet if the user imputs the correct password and then complete some other
tasks (the "other" portion I have figured out. The code is as follows:

Private Sub Worksheet_Activate()
If ActiveSheet.Protect = False Then
ActiveSheet.Unprotect
Rows("2:5000").Select
Selection.EntireRow.Hidden = False
Range("A1:L5004").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("A1").Select
End If

The issue is, if the user does not value the correct password, they
receive
an error. My question is: What is the code to be added so if the user
inputs
the correct password the code continues and if the incorrect password is
valued the execution aborts and the error meesage is not presented (I
realize
the user just needs to click "end" when then error is received, but I'd
like
to have a cleaner process).

Any and All Help Is Appreciated - Thank You




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Aborting Execution Before Error Message

Hi MWS,

Try handling the password directly:

'=============
Private Sub Worksheet_Activate()
Dim res As Variant

res = Application.InputBox _
(Prompt:="Enter password", Type:=3)

On Error GoTo XIT:
ActiveSheet.Unprotect password:=res
On Error GoTo 0


Rows("2:5000").Select
Selection.EntireRow.Hidden = False
Range("A1:L5004").Select
Selection.Sort Key1:=Range("A2"), _
Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("A1").Select
Exit Sub

XIT:
MsgBox "Your password was not recognised"""

End Sub
'<<=============

--
---
Regards,
Norman



"MWS" wrote in message
...
Norman, Thank You, this addresses the inputting of an incorrect password.

A point I failed to mention and perhaps you can help with is, if the user
chooses "cancel" instead of inputting a password at the prompt an error
message is displayed. Can this too be avoided with code and if so, what
would
it be?

Thanks Again - I Appreciate Your Help

"Norman Jones" wrote:

Hi MWS,

Try:

'=============
Private Sub Worksheet_Activate()
On Error GoTo XIT:
ActiveSheet.Unprotect
On Error GoTo 0
Rows("2:5000").Select
Selection.EntireRow.Hidden = False
Range("A1:L5004").Select
Selection.Sort Key1:=Range("A2"), _
Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("A1").Select
Exit Sub

XIT:
MsgBox "Your password was not recognised"""

End Sub
'<<=============


---
Regards,
Norman



"MWS" wrote in message
...
Hello, My goal is to have code to, upon activating a sheet, to
unprotect
the
sheet if the user imputs the correct password and then complete some
other
tasks (the "other" portion I have figured out. The code is as follows:

Private Sub Worksheet_Activate()
If ActiveSheet.Protect = False Then
ActiveSheet.Unprotect
Rows("2:5000").Select
Selection.EntireRow.Hidden = False
Range("A1:L5004").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("A1").Select
End If

The issue is, if the user does not value the correct password, they
receive
an error. My question is: What is the code to be added so if the user
inputs
the correct password the code continues and if the incorrect password
is
valued the execution aborts and the error meesage is not presented (I
realize
the user just needs to click "end" when then error is received, but I'd
like
to have a cleaner process).

Any and All Help Is Appreciated - Thank You






  #5   Report Post  
Posted to microsoft.public.excel.programming
MWS MWS is offline
external usenet poster
 
Posts: 53
Default Aborting Execution Before Error Message

Thank You Norman - I Appreciate Your Help!!!!

"Norman Jones" wrote:

Hi MWS,

Try handling the password directly:

'=============
Private Sub Worksheet_Activate()
Dim res As Variant

res = Application.InputBox _
(Prompt:="Enter password", Type:=3)

On Error GoTo XIT:
ActiveSheet.Unprotect password:=res
On Error GoTo 0


Rows("2:5000").Select
Selection.EntireRow.Hidden = False
Range("A1:L5004").Select
Selection.Sort Key1:=Range("A2"), _
Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("A1").Select
Exit Sub

XIT:
MsgBox "Your password was not recognised"""

End Sub
'<<=============

--
---
Regards,
Norman



"MWS" wrote in message
...
Norman, Thank You, this addresses the inputting of an incorrect password.

A point I failed to mention and perhaps you can help with is, if the user
chooses "cancel" instead of inputting a password at the prompt an error
message is displayed. Can this too be avoided with code and if so, what
would
it be?

Thanks Again - I Appreciate Your Help

"Norman Jones" wrote:

Hi MWS,

Try:

'=============
Private Sub Worksheet_Activate()
On Error GoTo XIT:
ActiveSheet.Unprotect
On Error GoTo 0
Rows("2:5000").Select
Selection.EntireRow.Hidden = False
Range("A1:L5004").Select
Selection.Sort Key1:=Range("A2"), _
Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("A1").Select
Exit Sub

XIT:
MsgBox "Your password was not recognised"""

End Sub
'<<=============


---
Regards,
Norman



"MWS" wrote in message
...
Hello, My goal is to have code to, upon activating a sheet, to
unprotect
the
sheet if the user imputs the correct password and then complete some
other
tasks (the "other" portion I have figured out. The code is as follows:

Private Sub Worksheet_Activate()
If ActiveSheet.Protect = False Then
ActiveSheet.Unprotect
Rows("2:5000").Select
Selection.EntireRow.Hidden = False
Range("A1:L5004").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("A1").Select
End If

The issue is, if the user does not value the correct password, they
receive
an error. My question is: What is the code to be added so if the user
inputs
the correct password the code continues and if the incorrect password
is
valued the execution aborts and the error meesage is not presented (I
realize
the user just needs to click "end" when then error is received, but I'd
like
to have a cleaner process).

Any and All Help Is Appreciated - Thank You






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
Code Execution Message canderson Excel Discussion (Misc queries) 1 October 9th 09 04:28 PM
How to ged rid of the "Execution Error 9" message at the file opening? frenchbox Excel Discussion (Misc queries) 0 July 31st 06 03:28 PM
message without stopping execution? Stefi Excel Programming 19 July 14th 05 12:08 PM
Code Execution has been interrupted message Rich in Yorktown Excel Programming 1 December 20th 04 05:41 PM
Message Box Execution Myrna Rodriguez Excel Programming 1 June 24th 04 06:34 PM


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

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"