Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-12-2017, 10:11 AM
NoSparks NoSparks is offline Macro to check against Columns & Delete Duplicates Windows 7 64bit Macro to check against Columns & Delete Duplicates Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default


Another approach is to use in memory arrays.
Attached Files
File Type: xlsm cjamps_MSOForum.xlsm (23.2 KB, 13 views)
Reply With Quote
  #2  
Old 12-12-2017, 10:24 AM
jolivanes jolivanes is offline Macro to check against Columns & Delete Duplicates Windows 10 Macro to check against Columns & Delete Duplicates Office 2013
Advanced Beginner
 
Join Date: Sep 2011
Posts: 91
jolivanes will become famous soon enough
Default

My bad.
I misread the first post. I understood it to mean 3 columns on the same row.
My apologies.
Reply With Quote
  #3  
Old 12-12-2017, 09:12 PM
jolivanes jolivanes is offline Macro to check against Columns & Delete Duplicates Windows 10 Macro to check against Columns & Delete Duplicates Office 2013
Advanced Beginner
 
Join Date: Sep 2011
Posts: 91
jolivanes will become famous soon enough
Default

Another long winded approach that might work.
Try on a copy of your original first.
Columns A, B and C have phone numbers to be compared to.
Column D has the phone numbers without bracketed area codes and a possible 1 in front
Columns E and F are empty and free to use.
Code:
Sub cjamps()
Dim i As Long, c As Range
Application.ScreenUpdating = False
    With Range("D2:D" & Cells(Rows.Count, "D").End(xlUp).Row)
        .Offset(, 1).Formula = "=IF(LEN(RC[-1])=13,RIGHT(RC[-1],12),RC[-1])"
        .Offset(, 1).Value = .Offset(, 1).Value
        .Offset(, 2).Formula = "= ""(""&LEFT(RC[-1],3)&"")""&"" ""&MID(RC[-1],5,3)&"" ""&MID(RC[-1],9,4)"
        .Offset(, 2).Value = .Offset(, 2).Value
    End With
    For Each c In Range("F2:F" & Cells(Rows.Count, "F").End(xlUp).Row)
        For i = 2 To Cells(Rows.Count, "F").End(xlUp).Row
            If WorksheetFunction.CountIf(Range(c.Offset(, -5).Address & ":" & c.Offset(, -3).Address), c.Value) <> 0 Then c.Offset(, -2).ClearContents: Exit For
        Next i
    Next c
    Columns("E:F").ClearContents
Application.ScreenUpdating = True
End Sub
Reply With Quote
  #4  
Old 12-13-2017, 07:20 AM
cjamps cjamps is offline Macro to check against Columns &amp; Delete Duplicates Windows 8 Macro to check against Columns &amp; Delete Duplicates Office 2010 32bit
Novice
Macro to check against Columns &amp; Delete Duplicates
 
Join Date: Mar 2017
Posts: 16
cjamps is on a distinguished road
Default

jolivanes,

I tried running the macro but it didn't delete the duplicates.
Reply With Quote
  #5  
Old 12-13-2017, 08:11 AM
jolivanes jolivanes is offline Macro to check against Columns &amp; Delete Duplicates Windows 10 Macro to check against Columns &amp; Delete Duplicates Office 2013
Advanced Beginner
 
Join Date: Sep 2011
Posts: 91
jolivanes will become famous soon enough
Default

For me it deleted the 1's where there were any and it deletes the dups.
I'll have a look later on.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to check against Columns &amp; Delete Duplicates VBA: Delete duplicates in each row bandaanders Excel Programming 2 09-02-2015 08:15 AM
Macro to check against Columns &amp; Delete Duplicates Excel vba to check to check if two columns are empty subspace3 Excel Programming 5 07-09-2015 04:45 PM
Macro to keep first instance and remove duplicates in certain column zhead Excel 2 03-18-2015 10:16 AM
Macro to check against Columns &amp; Delete Duplicates find and delete duplicates rcVBA Word VBA 4 05-15-2013 03:08 PM
Macro to check against Columns &amp; Delete Duplicates Deleting Duplicates in Macro jillapass Excel Programming 1 01-11-2012 10:02 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:16 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft