Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Excel > Excel

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 03-18-2015, 07:40 AM
zhead zhead is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Mar 2015
Location: Texas
Posts: 32
zhead is on a distinguished road
Default Macro to keep first instance and remove duplicates in certain column

Hi All,


I have the macro below that I run on several worksheets with no issues. But on all of them it runs on Column "A". I need to modify it to run on a different column on a new worksheet but I am not having any success. Can someone help?

Sub luxation() Dim N As Long N = Cells(Rows.Count, 1).End(xlUp).Row For i = N To 2 Step -1 If Cells(i, 1) = Cells(i - 1, 1) Then Cells(i, 1) = "" End If Next i End Sub
Reply With Quote
  #2  
Old 03-18-2015, 10:10 AM
Snakehips Snakehips is offline Windows 8 Office 2013
Advanced Beginner
 
Join Date: Mar 2015
Posts: 36
Snakehips is on a distinguished road
Default

zhead,

Perhaps ......

Code:
Sub luxation()
Dim N As Long
Dim c As Integer
'assumes you have the header selected (row 1) for your column of interest
If Selection.Columns.Count > 1 Then Exit Sub

col = Selection.Column  'sets the column number

N = Cells(Rows.Count, col).End(xlUp).Row
For i = N To 2 Step -1
If Cells(i, col) = Cells(i - 1, col) Then
Cells(i, col) = ""
End If
Next i

End Sub
Hope that helps.
Reply With Quote
  #3  
Old 03-18-2015, 10:16 AM
zhead zhead is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Mar 2015
Location: Texas
Posts: 32
zhead is on a distinguished road
Default

Snakehips,

Thanks very much for your quick reply.
It worked perfect.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help on duplicates in column; deciding which to keep based on other column nwcf Excel 3 01-31-2014 09:43 AM
Macro to remove blank column netchie Word VBA 4 03-14-2013 02:22 PM
Macro To Delete Instance across multiple slides. excelledsoftware PowerPoint 2 03-01-2012 07:29 PM
Deleting Duplicates in Macro jillapass Excel Programming 1 01-11-2012 10:02 AM
Macro to remove duplicates in Refrences list HowardC Word VBA 0 05-20-2010 09:57 AM


All times are GMT -7. The time now is 10:24 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft