Find match in list if match skip no match delete row

justvba

New Member
Joined
Jan 6, 2017
Messages
41
Hi I have a large list of parts that has duplicates and that's OK but I need to look at the part numbers on sheet2 and see if it is in sheet1. if in sheet one leave it alone if not in sheet 1 delete row. is there a fast way of doing this I am using 2016 excel VBA. here is my current code



Do Until IsEmpty(ActiveCell)
SearchItem = UCase(Trim(ActiveCell.Text))
OriginalSheet.Select
Range("A14").Select
Do Until ActiveCell.Value = SearchItem Or IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
Loop

If ActiveCell.Value = SearchItem Then
If IsEmpty(ActiveCell.Offset(0, 4)) Then
Sheets("Current Price").Select
ActiveCell.Offset(1, 0).Select
Else
Sheets("Current Price").Select
ActiveCell.EntireRow.Delete
End If

Else
Sheets("Current Price").Select
ActiveCell.EntireRow.Delete
End If

Loop
 
Last edited:
thank you that works great!!
I do want to ask if in the future I have to check the cell next to column a on sheet 1 to see if it has a value in it and if it does also delete the row on "Current Price" sheet how could I do that?
I thought I could add something in the IF n Is Nothing and offset(0,1) <> blank
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I do want to ask if in the future I have to check the cell next to column a on sheet 1 to see if it has a value in it and if it does also delete the row on "Current Price" sheet how could I do that?
I thought I could add something in the IF n Is Nothing and offset(0,1) <> blank

justvba,

I would have to see screenshots of both worksheets, before, and, worksheet Current Price after (manually formatted by you for the new results that you are now looking for).
 
Upvote 0
justvba,



Excel 2007
A
B
tire
hood
k
door
shoe5
shirt
34 green
toys
8

<colgroup><col style="width: 25pxpx"><col></colgroup><thead>
</thead><tbody>
mirror

<tbody>
</tbody>

</tbody>
Sheet1



Excel 2007
A
1
2
tire
3
hood
4
apples
5grapes
6orange
7red
8shorts
9toys
10toys
11tire
12shoe
13
computer
14
computer
15
soda
16

<colgroup><col style="width: 25pxpx"><col></colgroup><thead>
</thead><tbody>
</tbody>
Current price
ok lets try this.....
so I updated the sheets above and the final result would be the same as before but only those part that are blank in column "B" would show on current Price sheet. Make sense?
 
Upvote 0
so I updated the sheets above and the final result would be the same as before but only those part that are blank in column "B" would show on current Price sheet.

justvba,

And, the results on worksheet Current Price would look like?
 
Upvote 0
justvba,

I have some questions before I do any more coding, because your screenshots are not clear to me.



Excel 2007
ABCDEFGHIJ
1Sheet1ABCurrent PriceACurrent PriceA
21tire11tire
322tire2door
43hoodk3hood3shoe5
54door4apples4toys
65shoe55grapes5
76shirt34 green6orange6
87toys7red7
9888shorts8
109toys9
1110toys10
1211tire11
1312shoe12
1413computer13
1514computer14
1615soda15
17startresults
Instructions_NEW


In the above screenshots of worksheet Current Price, the results for worksheet Current Price is displayed in my column I?

Do both worksheets have column titles in row 1?
 
Last edited:
Upvote 0
justvba,

I have some questions before I do any more coding, because your screenshots are not clear to me.


Excel 2007
ABCDEFGHIJ
1Sheet1ABCurrent PriceACurrent PriceA
21tire11tire
322tire2door
43hoodk3hood3shoe5
54door4apples4toys
65shoe55grapes5
76shirt34 green6orange6
87toys7red7
9888shorts8
109toys9
1110toys10
1211tire11
1312shoe12
1413computer13
1514computer14
1615soda15
17startresults

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Instructions_NEW



In the above screenshots of worksheet Current Price, the results for worksheet Current Price is displayed in my column I?

Do both worksheets have column titles in row 1?
I am confused on why this is becoming so hard. it is the same exact set up as the first question.....
Sheet 1 starts at "A14" Column A = Part Column B = Comment
Sheet 2 (Current Price) data starts at "A2"
Sheet 2 results (Current Price) Data stays at "A2" but only show the Parts where Column B cell is blank
 
Upvote 0
justvba,

Last try!

1. Is the following screenshot correct?


Excel 2007
AB
1
2
3
4
5
6
7
8
9
10
11
12
13
14tire
15
16hoodk
17door
18shoe5
19shirt34 green
20toys
218
22
Sheet1


2. Is the following screenshot correct?


Excel 2007
A
1
2tire
3hood
4apples
5grapes
6orange
7red
8shorts
9toys
10toys
11tire
12shoe
13computer
14computer
15soda
16
Current Price


3. And, is the following screenshot correct for the results you are looking for?


Excel 2007
A
1tire
2door
3shoe5
4toys
5
6
7
8
9
10
11
12
13
14
15
16
Current Price
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,955
Members
449,199
Latest member
Riley Johnson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top