Question : Deleting Duplicate entries in 2 different sheets

Hello everyone

I have an Excel Sheet with several sheets and I would like to delete double entries automatically.


If Data is typed in sheet 1 it should be deleted in sheet 2 if it is the same.

I now have the following code



1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Private Sub Worksheet_Change(ByVal Target As Range)

   For Each ChkRng In ActiveSheet.Range("CustomerShippedItaly")
       If Target.Address = ChkRng.Address Then
           For Each DelRng In OpenItaly.Range("CustomerOpenItaly")
               If Target.Value = DelRng.Value Then
                   DelRng.ClearContents
               End If
           Next
       End If
   Next
End Sub


But if the same data is typed in into the active sheet nothing happens in the sheet "openitaly"

Thanks for your answers

Answer : Deleting Duplicate entries in 2 different sheets

try this,

It uses column A only, and used Find to quickly find and delete macthing rows (one or more) in OpenItaly

The fast find code is based on  http://www.experts-exchange.com/A_29119.html

Cheers

Dave
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim ws As Worksheet
    Dim rng1 As Range
    Dim rng2 As Range
    Dim cel1 As Range

    If Application.Intersect(Columns("A"), Target) Is Nothing Then Exit Sub

    With Application
        .ScreenUpdating = False
    End With

    Set ws = Sheets("OpenItaly")
    Set rng1 = ws.Range(ws.[a2], ws.Cells(Rows.Count, "A").End(xlUp))
    Set cel1 = rng1.Find(Target.Value, , xlValues, xlWhole, xlByRows, , False)
    If Not cel1 Is Nothing Then
        Set rng2 = cel1
        strFirstAddress = cel1.Address
        Do
            Set cel1 = rng1.FindNext(cel1)
            Set rng2 = Union(rng2.EntireRow, cel1)
        Loop While strFirstAddress <> cel1.Address
    End If

    If Not rng2 Is Nothing Then rng2.EntireRow.Delete
    Application.ScreenUpdating = True
 
End Sub
Random Solutions  
 
programming4us programming4us