LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default need help with password protection and macro

to the following syntax what can be added so that I can put a password (2468)
on the protection of the sheet. Right now, this sheet automatically protects
itself and I want to add a password. Can a macro automatically enter a
password (2468) upon its protection of the sheet?

Option Explicit

Private Sub worksheet_change(ByVal target As Range)
Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
If target.Count 1 Then GoTo exitHandler

On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler

If rngDV Is Nothing Then GoTo exitHandler

If Intersect(target, rngDV) Is Nothing Then
'do nothing
Else
Application.EnableEvents = False
newVal = target.Value
Application.Undo
oldVal = target.Value
target.Value = newVal
If target.Column = 11 Then
If oldVal = "" Then
'do nothing
Else
If newVal = "" Then
'do nothing
Else
target.Value = oldVal _
& ", " & newVal
End If
End If
End If
End If

exitHandler:
Application.EnableEvents = True

If target.Cells.Count 1 Then Exit Sub
If target.Row < 10 Or target.Row 13 Then Exit Sub
Application.EnableEvents = False
If target.Column = 2 Then
If IsNumeric(target) = False Then
If Len(target) 0 Then
target.Offset(0, 4) = ""
End If
End If
End If
Application.EnableEvents = True
End Sub

Thank You
 
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
Password protection in macro ( Anybody can view my password in VB Sherees Excel Discussion (Misc queries) 2 January 24th 10 10:05 PM
Excel Data Protection- AKA: Sheet/Macro Password Protection Mushman(Woof!) Setting up and Configuration of Excel 0 December 29th 09 06:50 AM
password protection macro - HELP???? Teddy-B Excel Discussion (Misc queries) 4 October 10th 08 03:55 PM
Macro override password protection Cheryl Excel Programming 1 June 15th 04 03:08 AM
How to add a macro with password protection PleaseHelpMe Excel Programming 2 March 5th 04 08:55 PM


All times are GMT +1. The time now is 12:38 PM.

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"