Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
My read was that you wanted to have it deny duplicate entries 'as they are
typed' similar to the Data Validation feature except that the latter allows you to specify only what is allowed as opposed to what is denied. Paste the following to the worksheet code module:- Private Sub Worksheet_Change(ByVal Target As Range) Dim rng1 As Range, rng2 As Range Dim ws2 As Worksheet Dim c As Range Dim Msg As String, Title As String Set ws2 = Sheets("Sheet2") Set rng1 = Me.Columns(1) Set rng2 = ws2.Range(ws2.Range("A1"), _ ws2.Range("A1").End(xlDown)) If Target.Count 1 Then Exit Sub Title = "Data Validation" If Not Intersect(Target, rng1) Is Nothing Then Set c = rng2.Find(Target.Value, , , xlWhole) If Not c Is Nothing Then With Target ..Select Msg = "Entry denied !!!" & vbCr & vbCr & _ "The word """ & .Value & _ """ already exists on " & rng2.Parent.Name & ". " MsgBox Msg, vbCritical, Title ..ClearContents End With End If End If Set rng1 = Nothing Set rng2 = Nothing Set c = Nothing End Sub Regards, Greg "ChristalClarity" wrote: I want to structure a macro that will automatically search entries in a colunm on worksheet A, compare those entries to a column in spreadsheet B and then disallow the entry if there is a match. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro to disallow shading in certain columns | Excel Worksheet Functions | |||
In Excel, how can I tell the program to disallow duplicate data i. | Excel Worksheet Functions | |||
Excel XP VBA code to search all macro code in Excel module for specific search string criteria | Excel Programming | |||
Excel XP VBA code to search all macro code in Excel module for specific search string criteria | Excel Programming |