PC Review


Reply
Thread Tools Rate Thread

Delete rows where colums match

 
 
Del_F
Guest
Posts: n/a
 
      15th Aug 2007
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.

 
Reply With Quote
 
 
 
 
Del_F
Guest
Posts: n/a
 
      15th Aug 2007
On 15 Aug, 15:52, Del_F <djfair...@gmail.com> 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.

 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      15th Aug 2007
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.
>
>

 
Reply With Quote
 
Del_F
Guest
Posts: n/a
 
      16th Aug 2007
Thanks Joel,
Nice solution - works perfectly!
D.


On 15 Aug, 16:40, Joel <J...@discussions.microsoft.com> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete rows where colums 4 is empty Robert Microsoft Excel Programming 7 10th Jul 2007 01:26 PM
delete blank rows & colums =?Utf-8?B?UWF6aSBBaG1hZA==?= Microsoft Excel Misc 3 26th Dec 2006 05:32 AM
VB Delete rows that do not match criteria =?Utf-8?B?cmxlZTE5OTk=?= Microsoft Excel Programming 2 1st Nov 2006 11:19 PM
how do I delete all rows that match a condition? =?Utf-8?B?ZGpoczYz?= Microsoft Excel Worksheet Functions 5 16th Mar 2005 03:55 PM
Delete all nonused rows and colums Marcus Pedersén Microsoft Excel Discussion 2 1st Aug 2004 08:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:10 PM.