Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default find and delete

I need a macro that will look in columns A and B and when there is a
match found it will delete that entire row.
Column B doesnt have duplicates however column A does. So if whats in
column B is found in column A I need those rows deleted.
Example:

Column A Column B Column C Column D
Item ID Item ID Item Disc Location Code
SR0512 SR0512 oxygen tank 1
SR0512 SR0513 oxygen tank 10
SR0512 SR0514 oxygen tank 15
SR0512 SR0515 oxygen tank 20
SR0513 wheelchair 1
SR0513 wheelchair 10
SR0514 commode 30
SR0515 vent 35
SR0516 c-pap 40
SR0516 c-pap 45

I would like the outcome to look like this

Column A Column B Column C Column D
Item ID Item ID Item Disc Location Code
SR0516 c-pap 40
SR0516 c-pap 45

  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default find and delete

try:

Sub Test()
Dim rngA As Range
Dim rngCell As Range
Dim rngDelete As Range
Dim varB As Variant

Set rngA = Range("A2:A11")
varB = Range("B2:B11").Value

For Each rngCell In rngA.Cells
If IsNumeric(Application.Match(rngCell.Value, varB, 0)) Then
If rngDelete Is Nothing Then
Set rngDelete = rngCell
Else: Set rngDelete = Union(rngDelete, rngCell)
End If
End If
Next rngCell

If Not rngDelete Is Nothing Then _
rngDelete.EntireRow.Delete

End Sub



" wrote:

I need a macro that will look in columns A and B and when there is a
match found it will delete that entire row.
Column B doesnt have duplicates however column A does. So if whats in
column B is found in column A I need those rows deleted.
Example:

Column A Column B Column C Column D
Item ID Item ID Item Disc Location Code
SR0512 SR0512 oxygen tank 1
SR0512 SR0513 oxygen tank 10
SR0512 SR0514 oxygen tank 15
SR0512 SR0515 oxygen tank 20
SR0513 wheelchair 1
SR0513 wheelchair 10
SR0514 commode 30
SR0515 vent 35
SR0516 c-pap 40
SR0516 c-pap 45

I would like the outcome to look like this

Column A Column B Column C Column D
Item ID Item ID Item Disc Location Code
SR0516 c-pap 40
SR0516 c-pap 45


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
find and delete Karen[_3_] Excel Worksheet Functions 0 March 5th 08 03:14 AM
Find and Delete Row Keyrookie Excel Worksheet Functions 1 October 16th 07 08:33 PM
Find and delete! Philip Drury Excel Discussion (Misc queries) 0 October 3rd 07 02:36 PM
find and delete duplicate entries in two columns or find and prin. campare 2 columns of numbers-find unique Excel Programming 1 November 24th 04 04:09 PM
find and delete text, find a 10-digit number and put it in a textbox Paul Excel Programming 3 November 16th 04 04:21 PM


All times are GMT +1. The time now is 10:34 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"