Excel 2002 problem

ExHell

Board Regular
Joined
Aug 4, 2003
Messages
55
i have been using this spreadsheet for years,since upgrading to 2002
when i activate this sheet I get a password prompt.
Can you please help?
Private Sub worksheet_activate()
ActiveSheet.Protect UserInterfaceOnly:=True
Application.ScreenUpdating = False
BEL1
Application.StatusBar = ""

ActiveWindow.ScrollRow = 1
ActiveWindow.ScrollColumn = 1
If range("m24") > 1 Then
MsgBox "You have got more then one system checked you should have only a 1 in one box "
End If
If range("n4") > "" Then
ActiveSheet.Unprotect password:="rp"
range("L4:N4").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
range("b200").Select

ActiveSheet.Protect password:="rp"
End If
If range("n4") = 0 Then
ActiveSheet.Unprotect password:="rp"
range("L4:N4").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
ActiveSheet.Protect password:="bhprp"
range("b200").Select
End If
ActiveSheet.Protect password:="rp"
Application.StatusBar = ""
range("AW") = 0

ActiveSheet.Protect UserInterfaceOnly:=False
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hello,
fine you are ex-hell ! :)
I wouldn't like to be in there :(
reducing your code to what's important to your problem
Code:
Private Sub worksheet_activate()
ActiveSheet.Protect UserInterfaceOnly:=True

If Range("n4") > "" Then
ActiveSheet.Unprotect Password:="rp"

ActiveSheet.Protect Password:="rp"
End If
If Range("n4") = 0 Then
ActiveSheet.Unprotect Password:="rp"

ActiveSheet.Protect Password:="bhprp"

End If
ActiveSheet.Protect Password:="rp"

ActiveSheet.Protect UserInterfaceOnly:=False
End Sub
just unprotect your sheet at the start of your macro and protect at the end
using the SAME password (only one key to heaven :) )

does this help ?
kind regards,
Erik
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,546
Messages
5,838,018
Members
430,526
Latest member
NiceGuyWithExcel2007

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top