Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro needed to delete rows
I have a list of numbers that I want to narrow down to unique numbers....in
other words, I want to delete the row if a number show is already displayed elsewhere. Example list: 1 2 2 2 3 4 4 4 I am searching for a macro that will delete the rows containing the extras "2's" and "4's". |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro needed to delete rows
Sub DeleteDups()
Dim lastrow as Long, i as Long Dim rng as Range With Worksheets("Sheet1") lastrow = .Cells(rows.count,"A").End(xlup).Row for i = lastrow to 2 step - 1 set rng = .Range(.cells(1,"A"),.Cells(i-1,"A")) if application.Countif(rng,.cells(i,"A").Value)0 then rows(i).Delete end if Next End With End Sub -- Regards, Tom Ogilvy "simmerdown" wrote: I have a list of numbers that I want to narrow down to unique numbers....in other words, I want to delete the row if a number show is already displayed elsewhere. Example list: 1 2 2 2 3 4 4 4 I am searching for a macro that will delete the rows containing the extras "2's" and "4's". |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro needed to delete rows
Try the following
Sub AAA() Dim LastRow As Long Dim RowNdx As Long LastRow = Cells(Rows.Count, "A").End(xlUp).Row For RowNdx = LastRow To 2 Step -1 If Cells(RowNdx, "A") = Cells(RowNdx - 1, "A") Then Rows(RowNdx).Delete End If Next RowNdx End Sub This assumes your data is in column A and starts in row 1. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "simmerdown" wrote in message ... I have a list of numbers that I want to narrow down to unique numbers....in other words, I want to delete the row if a number show is already displayed elsewhere. Example list: 1 2 2 2 3 4 4 4 I am searching for a macro that will delete the rows containing the extras "2's" and "4's". |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro needed to delete rows
One easy way is to use datafilteradvanced filterunique itemscopy
elsewhere. Record a macro if desired. -- Don Guillett SalesAid Software "simmerdown" wrote in message ... I have a list of numbers that I want to narrow down to unique numbers....in other words, I want to delete the row if a number show is already displayed elsewhere. Example list: 1 2 2 2 3 4 4 4 I am searching for a macro that will delete the rows containing the extras "2's" and "4's". |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro needed to delete rows
Thank you very much, Tom
"simmerdown" wrote: I have a list of numbers that I want to narrow down to unique numbers....in other words, I want to delete the row if a number show is already displayed elsewhere. Example list: 1 2 2 2 3 4 4 4 I am searching for a macro that will delete the rows containing the extras "2's" and "4's". |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro needed to identify value and delete row if value below targe | New Users to Excel | |||
Macro needed for inserting blank rows | Excel Worksheet Functions | |||
Combing and Adding Data in Multiple Rows (Macro Needed) | Excel Programming | |||
macro to delete entire rows when column A is blank ...a quick macro | Excel Programming |