PC Review


Reply
Thread Tools Rate Thread

Compare Validation Operator give error

 
 
tskogstrom
Guest
Posts: n/a
 
      1st Dec 2006
Hi,

I have code to restore validation in cells if any paste over new cells.
I have noticed that changing validation demand a unprotected workbook
and unprotection empty the clipbook. Since I don't wan't to empty the
clipbook, I try to check if there is a validation and if it is - if it
is right one. With this, I just empty clipbook if I need to.
- This done by trying to compare Operators as following code:

BUT I get 1004 error on "If .Operator = .." line. Why?
Can anybody see the reason?
Kind regards
/tskogstrom


Sub ValidationPercent(rng As Range)

If Not rng.Validation Is Nothing Then ' if validation-> is it correct
one?
With rng.Validation
If .Operator = xlBetween Then
If .Formula1 = "0" And .Formula2 = "100" Then
GoTo endcode
Else:
GoTo validationcode
End If
End If
End With
Else:
GoTo validationcode
End If
Exit Sub

validationcode:
Call UnProtectWB
With rng.Validation
.Delete
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop,
_
Operator:=xlBetween, Formula1:="0", Formula2:="100"
.IgnoreBlank = False
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Call ProtectWB
endcode:
End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Like operator and wildcards, compare fields titlepusher Microsoft Access Queries 2 21st Oct 2008 03:57 PM
macro to compare 2 dates and give a info mess if less than 1 wk =?Utf-8?B?RWxhaW5l?= Microsoft Access Getting Started 3 16th Jun 2006 05:17 PM
generic problem with operator. compile error: operator * is not allowedon type T. SharpKnight Microsoft C# .NET 2 20th Feb 2006 01:08 PM
compare 2 dates and give the date conditions are met chin_un_len Microsoft Excel Programming 0 14th Feb 2006 12:40 AM
Converting T-SQL -> Access give Syntax error (missing operator) inquery expression Andrew John Microsoft Access Queries 3 1st Sep 2004 12:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:43 PM.