+ Reply to Thread
Results 1 to 3 of 3

Find Duplicates if found clear specific cells

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-29-2008
    Location
    usa
    MS-Off Ver
    EXCEL 2010
    Posts
    116

    Find Duplicates if found clear specific cells

    I have this macro that clears entire row when duplicates are found on column B so I would like to changed to where it only clear specific cells
    I will like to clear from cell 1 to 20 and cell 25
    Any help on this will greatly appreciated thank you for your time
    Sub ClearDupRows()
    Dim StartRow As Long
    Dim EndRow As Long
    Dim R As Long
    With Application
    .ScreenUpdating = False
    .Calculation = xlCalculationManual
    .EnableEvents = False
    End With
    StartRow = 1
    EndRow = Cells(StartRow, "B").End(xlDown).Row
    For R = EndRow To StartRow Step -1
    If Application.CountIf(Range(Cells(1, "B"), _
    Cells(R, "B")), Cells(R, "B").Value) > 1 Then
    Rows(R).Clear
    End If
    Next R
    With Application
    .ScreenUpdating = True
    .Calculation = xlCalculationAutomatic
    .EnableEvents = True
    End With
    End Sub
    Last edited by martinez_pedro; 04-20-2011 at 12:19 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Find Duplicates if found clear specific cells

    Maybe change this:
    Rows(R).Clear

    ...to this:
    Range("A" & R).Resize(,20).Clear
    Range("Y" & R).Clear
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    09-29-2008
    Location
    usa
    MS-Off Ver
    EXCEL 2010
    Posts
    116

    Re: Find Duplicates if found clear specific cells

    Thank you very much it works

+ 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