Data validation not working

waheed254

Board Regular
Joined
Jan 2, 2014
Messages
62
Dear All,
I am facing problem regarding Data Validation that when i Type data in data validation activated cell it shows error when i type Data which is not available in my list but when i copy Paste/Paste Special in Same cell it do not show error it just Paste value if it is in my list or Not. I think an error must be displayed while copy pasting data if it is not in my specified List if Source Data...


Can anyone Help...
 
Try
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim ChangedC As Range, ChangedD As Range, c As Range, Found As Range
  Dim DVListC As Range, DVLIstD As Range
  Dim sInvalid As String
  Dim val As Variant
  
  Set DVListC = Sheets("DLR").Range("D4:D3000")
  Set DVLIstD = Sheets("DLR").Range("E4:E3000")
  
  Set ChangedC = Intersect(Target, Range("C4:C5000"))
  Set ChangedD = Intersect(Target, Range("D4:D5000"))
  
  Application.EnableEvents = False
  If Not ChangedC Is Nothing Then
    For Each c In ChangedC
      val = c.Value
      If Len(val) Then
        Set Found = DVListC.Find(What:=val, LookIn:=xlValues, _
            LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
        If Found Is Nothing Then
          sInvalid = sInvalid & vbLf & c.Address(0, 0) & vbTab & val
          c.Interior.ColorIndex = 3
        Else
          c.Interior.ColorIndex = xlNone
        End If
      End If
    Next c
  End If
  
  If Not ChangedD Is Nothing Then
    For Each c In ChangedD
      val = c.Value
      If Len(val) Then
        Set Found = DVLIstD.Find(What:=val, LookIn:=xlValues, _
            LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
        If Found Is Nothing Then
          sInvalid = sInvalid & vbLf & c.Address(0, 0) & vbTab & val
          c.Interior.ColorIndex = 3
        Else
          c.Interior.ColorIndex = xlNone
        End If
      End If
    Next c
  End If
  Application.EnableEvents = True
  
  If Len(sInvalid) Then
    MsgBox "The following entries were invalid and have been highlighted" & sInvalid
  End If
  
End Sub
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Fantastic that is Brilliant thank u very much again..... I am not closing this thread if any issue rises i shall Post, else i shall close....
 
Upvote 0
Fantastic that is Brilliant thank u very much again..... I am not closing this thread if any issue rises i shall Post, else i shall close....
There is no option to 'Close' a thread in this forum. We like to leave them open because another member may come along later and offer a much better solution.

A post that a suggestion satisfies your current need (as you have done) is a sufficient conclusion to your thread.
 
Upvote 0

Forum statistics

Threads
1,216,235
Messages
6,129,650
Members
449,524
Latest member
RAmraj R

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top