Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Data Validation - copy/paste

I use data validation often and know that copy/paste will not only skip
validation but also over-write the data validation. Copy/paste special will
skip validation but the rule remains in place.

Assuming I have code to re-instate the proper data validation, is there a
way to flag entries that don't comply with the data validation - or do I have
to write independent code to check entries that may have been pasted?

Excel 2003

THanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Data Validation - copy/paste

Ken
You can use a Worksheet_Change event macro to look at the entry whenever
a change is made in the entry. That macro can then search the Data
Validation list for that entry and take whatever action you want if the
entry is not in that list. Something like the following perhaps. I assumed
your list is named MyList and the DV cell is A1. Note that this macro
resets the Data Validation in A1. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Not Intersect(Target, Range("A1")) Is Nothing Then
If Range("MyList").Find(What:=Target.Value, LookAt:=xlWhole) Is
Nothing Then
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
Target.Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _
xlBetween, Formula1:="=MyList"
End With
MsgBox "You must select from the list.", 16, "Invalid Entry"
End If
End If
End Sub
"Ken Valenti" wrote in message
...
I use data validation often and know that copy/paste will not only skip
validation but also over-write the data validation. Copy/paste special
will
skip validation but the rule remains in place.

Assuming I have code to re-instate the proper data validation, is there a
way to flag entries that don't comply with the data validation - or do I
have
to write independent code to check entries that may have been pasted?

Excel 2003

THanks in advance!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Data Validation - copy/paste

Thanks for your reply - but that still requires to write code to match the
data validation.

Also, using a worksheet change event will disable "Undo" and since I
already have a Check Data macro that is run before submitting data to the
database, I just want to ensure that data validation has done it's job. That
way other people can change the data validation without having to change any
code.

Here's the closest thing I can come up with to do what I want.

ActiveSheet.CircleInvalid

I still don't know how to programatically check if invalid cells exist, or
what cells are invalid but, but can visibly see invalid entries.

Thanks again,

Ken

"Otto Moehrbach" wrote:

Ken
You can use a Worksheet_Change event macro to look at the entry whenever
a change is made in the entry. That macro can then search the Data
Validation list for that entry and take whatever action you want if the
entry is not in that list. Something like the following perhaps. I assumed
your list is named MyList and the DV cell is A1. Note that this macro
resets the Data Validation in A1. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Not Intersect(Target, Range("A1")) Is Nothing Then
If Range("MyList").Find(What:=Target.Value, LookAt:=xlWhole) Is
Nothing Then
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
Target.Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _
xlBetween, Formula1:="=MyList"
End With
MsgBox "You must select from the list.", 16, "Invalid Entry"
End If
End If
End Sub
"Ken Valenti" wrote in message
...
I use data validation often and know that copy/paste will not only skip
validation but also over-write the data validation. Copy/paste special
will
skip validation but the rule remains in place.

Assuming I have code to re-instate the proper data validation, is there a
way to flag entries that don't comply with the data validation - or do I
have
to write independent code to check entries that may have been pasted?

Excel 2003

THanks in advance!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Data Validation - copy/paste

Here's the code I was looking for

Sub IdentifyInvalidEntries()
Cells.ClearComments
Dim TempCell As Range
For Each TempCell In ActiveSheet.UsedRange
If Not TempCell.Validation.Value Then TempCell.AddComment "Invalid Entry"
Next
ActiveSheet.CircleInvalid
End Sub



"Ken Valenti" wrote:

I use data validation often and know that copy/paste will not only skip
validation but also over-write the data validation. Copy/paste special will
skip validation but the rule remains in place.

Assuming I have code to re-instate the proper data validation, is there a
way to flag entries that don't comply with the data validation - or do I have
to write independent code to check entries that may have been pasted?

Excel 2003

THanks in advance!

Reply
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
Data Validation - copy paste ! Christoffer Bloch Andersen Excel Worksheet Functions 1 March 18th 09 01:22 PM
Data Validation (copy paste error) Christoffer Bloch Andersen Excel Worksheet Functions 0 February 3rd 09 01:45 PM
data validation and copy/paste....... MPR Excel Programming 3 July 27th 06 03:02 PM
Copy/Paste over rides data validation jk Setting up and Configuration of Excel 1 July 23rd 06 03:39 AM
Data validation does not seem to work with copy/paste LAF Excel Discussion (Misc queries) 1 September 15th 05 09:31 PM


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