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: 92
Default Compare Validation Operator give error

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

 
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
Macro or formula to compare columns and give a result of the odd o Rhett C[_2_] Excel Discussion (Misc queries) 2 December 24th 09 02:26 AM
how do i give differect color for validation list? imratish Excel Discussion (Misc queries) 2 November 19th 07 07:57 AM
compare 2 dates and give the date conditions are met chin_un_len[_12_] Excel Programming 0 February 14th 06 12:40 AM
corrupt program or file? How to tell? Or is it operator error? [email protected] Excel Discussion (Misc queries) 6 January 17th 06 12:40 PM
Syntax error (missing operator) in query expression '6 Wescott Rd# shealy Excel Discussion (Misc queries) 0 June 9th 05 09:53 PM


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