Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro needed to identify value and delete row if value below targe Pyrotoy New Users to Excel 3 December 9th 08 11:35 PM
Macro needed for inserting blank rows sunslight Excel Worksheet Functions 2 January 12th 07 05:58 PM
Combing and Adding Data in Multiple Rows (Macro Needed) [email protected] Excel Programming 11 August 6th 05 07:15 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM


All times are GMT +1. The time now is 12:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"