Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Delete rows where colums match

Hi,
I have 2 columns (A & B) of text data, and I want to delete every row
where the same term appears in both columns. So... for each row (n),
delete the row only if An and Bn match.
Any help much appreciated.
Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Delete rows where colums match

On 15 Aug, 15:52, Del_F wrote:
Hi,
I have 2 columns (A & B) of text data, and I want to delete every row
where the same term appears in both columns. So... for each row (n),
delete the row only if An and Bn match.
Any help much appreciated.
Thanks.


Okay, I figured it out, using some previously posted code:

Sub Redundancy()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 2 Step -1
If Not IsError(Application.Match(Cells(i, "A").Value, _
Range("B:B"), 0)) Then
Cells(i, "A").Delete Shift:=xlUp
End If
Next i

End Sub

D.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Delete rows where colums match

Sub test2()
RowCount = 1
Do While Not IsEmpty(Cells(RowCount, "A"))
If Cells(RowCount, "A") = Cells(RowCount, "B") Then
Cells(RowCount, "A").EntireRow.Delete
Else
RowCount = RowCount + 1
End If
Loop
End Sub


"Del_F" wrote:

Hi,
I have 2 columns (A & B) of text data, and I want to delete every row
where the same term appears in both columns. So... for each row (n),
delete the row only if An and Bn match.
Any help much appreciated.
Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Delete rows where colums match

Thanks Joel,
Nice solution - works perfectly!
D.


On 15 Aug, 16:40, Joel wrote:
Sub test2()
RowCount = 1
Do While Not IsEmpty(Cells(RowCount, "A"))
If Cells(RowCount, "A") = Cells(RowCount, "B") Then
Cells(RowCount, "A").EntireRow.Delete
Else
RowCount = RowCount + 1
End If
Loop
End Sub



"Del_F" wrote:
Hi,
I have 2 columns (A & B) of text data, and I want to delete every row
where the same term appears in both columns. So... for each row (n),
delete the row only if An and Bn match.
Any help much appreciated.
Thanks.- Hide quoted text -


- Show quoted text -



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
Delete rows where colums 4 is empty Robert[_30_] Excel Programming 7 July 10th 07 01:26 PM
delete blank rows & colums Qazi Ahmad Excel Discussion (Misc queries) 3 December 26th 06 05:32 AM
Delete rows that do not match criteria rlee1999 Excel Programming 1 November 3rd 06 03:16 PM
VB Delete rows that do not match criteria rlee1999 Excel Programming 2 November 1st 06 11:19 PM
how do I delete all rows that match a condition? djhs63 Excel Worksheet Functions 5 March 16th 05 03:55 PM


All times are GMT +1. The time now is 05:50 AM.

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

About Us

"It's about Microsoft Excel"