Solved

Excel Macro: Delete a Row if Column A and B match (in that Row)

Posted on 2016-08-04
2
65 Views
Last Modified: 2016-08-05
Header           A              B
Row1             Joe          Frank
Row2             Bob         Bob
Row3             Bill          Owen
Row4             Kelly       Kelly


The macro would delete Rows #2  and  #4

Thank you.
0
Comment
Question by:K B
2 Comments
 
LVL 51

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 41743297
Here is a pretty simple approach, see if this meets your needs.

Public Sub CleanUp()
   Application.ScreenUpdating = False
   With ActiveSheet
      For i = .Cells(.Rows.Count, 1).End(xlUp).Row To 2 Step -1
         If Cells(i, "B").Value = Cells(i, "C").Value Then
             .Rows(i).Delete
         End If
      Next
   End With
   Application.ScreenUpdating = True
End Sub

Open in new window

~bp
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 41743335
I think Bill's line 5 should be

 If Cells(i, "A").Value = Cells(i, "B").Value Then
1

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Access printing shortcut in Ms Access 10 35
TT Status Chang 3 30
Delete rows if they are duplicates 3 13
onOpen 14 39
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now