+ Reply to Thread
Results 1 to 3 of 3

Deleting duplicates

  1. #1
    Judd Jones
    Guest

    Deleting duplicates

    I found this code here:

    Sub DeleteDuplicates()
    'Deletes Duplicates in column called out "C"
    Dim LastRow As Long
    Dim i As Long
    Application.ScreenUpdating = False
    LastRow = Range("C" & Rows.Count).End(xlUp).Row
    For i = LastRow To 1 Step -1
    If WorksheetFunction.CountIf(Range("C:C"), Range("C" & i)) > 1 Then
    Range("C" & i).EntireRow.Delete
    End If
    Next 'i
    Application.ScreenUpdating = True
    End Sub

    I am needing this changed to only delete column C and D.

    Thanks in advance.

  2. #2
    Sharad Naik
    Guest

    Re: Deleting duplicates

    Replace " Range("C" & i).EntireRow.Delete "
    With:
    Range("C" & i & ":D" & i).Delete Shift:=xlUp

    This is assuminng you want to shift cells up.
    In case you want to shift cell to left replace
    xlUp with xlToLeft

    Sharad

    "Judd Jones" <[email protected]> wrote in message
    news:[email protected]...
    >I found this code here:
    >
    > Sub DeleteDuplicates()
    > 'Deletes Duplicates in column called out "C"
    > Dim LastRow As Long
    > Dim i As Long
    > Application.ScreenUpdating = False
    > LastRow = Range("C" & Rows.Count).End(xlUp).Row
    > For i = LastRow To 1 Step -1
    > If WorksheetFunction.CountIf(Range("C:C"), Range("C" & i)) > 1 Then
    > Range("C" & i).EntireRow.Delete
    > End If
    > Next 'i
    > Application.ScreenUpdating = True
    > End Sub
    >
    > I am needing this changed to only delete column C and D.
    >
    > Thanks in advance.




  3. #3
    K Dales
    Guest

    RE: Deleting duplicates

    Not clear what you are asking: Routine you give deletes entire row if value
    in column C is duplicated (within column C). You want to do this for "only C
    and D", but that could mean:
    - find rows in C that are duplicated in C, delete; then same for D
    - find rows where both C and D are duplicated and delete these rows
    - find rows where C and/or D are duplicated and delete (erase?) "only C and D"

    "Judd Jones" wrote:

    > I found this code here:
    >
    > Sub DeleteDuplicates()
    > 'Deletes Duplicates in column called out "C"
    > Dim LastRow As Long
    > Dim i As Long
    > Application.ScreenUpdating = False
    > LastRow = Range("C" & Rows.Count).End(xlUp).Row
    > For i = LastRow To 1 Step -1
    > If WorksheetFunction.CountIf(Range("C:C"), Range("C" & i)) > 1 Then
    > Range("C" & i).EntireRow.Delete
    > End If
    > Next 'i
    > Application.ScreenUpdating = True
    > End Sub
    >
    > I am needing this changed to only delete column C and D.
    >
    > Thanks in advance.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1