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: 10
Default Worksheet_Change stopped working after sheet is protected

Hello world

I am still a newbie with VBA and it took me quite a long time to build
(with your help ofcourse) code presented below

------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)

'Does the validation range still have validation?

If HasValidation(Range("E2:E1001")) = False Or
HasValidation(Range("F2:F1001")) = False Or
HasValidation(Range("U2:U1001")) = False _
Or HasValidation(Range("AJ2:AJ1001")) = False Or
HasValidation(Range("AN2:AN1001")) = False Or Range("check") 0 Then

Application.Undo

MsgBox "Operation canceled. It would destroy validation data",
vbCritical '

Else

Exit Sub
End If

End Sub



Private Function HasValidation(r) As Boolean

' Returns True if every cell in Range r uses Data Validation

On Error Resume Next

x = r.Validation.Type

If Err.Number = 0 Then HasValidation = True Else HasValidation =
False

End Function
-----------------------------------

It worked very well (filed check is sum of column in which 0 means data
in range are ok, 1 are not ok) and I was very satisfied for a moment
but then I put protection on sheet and the code just stopped working. I
have no errors. It just let me destroy validation data format without
msg box. When I unprotect sheet it is working propely again.

I am very confused

Any help appreciated
PAT

 
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
Excel 07 formulas on a whole spread sheet stopped working Steve Excel Discussion (Misc queries) 2 August 30th 09 03:35 PM
Filters not working on Protected sheet Krishna Kumar L Excel Discussion (Misc queries) 1 February 9th 09 07:08 AM
Data Validation has stopped working on one paricular sheet only Tarby Excel Worksheet Functions 3 May 21st 07 02:24 PM
Worksheet_Change stoped working after sheet is protected [email protected] Excel Programming 5 November 30th 06 09:46 AM
Edit / Move or copy sheet stopped working in Excel 2003 kris2u Excel Worksheet Functions 0 October 4th 05 08:20 PM


All times are GMT +1. The time now is 07:16 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"