Find and replace as well as find and delete

wal_verin

New Member
Joined
Nov 21, 2018
Messages
15
Hi all, I saw a post by Trebor76 that has helped me to come a few steps forward, but i still have alot to solve and i need the help of some skilled VBA Excel users. I am quite at the basic level in Excel VBA and i will really be thankful if someone can take sometime to help me out

I have data in two sheets, termed Sheet 1 and Sheet 2 as shown below. The idea is that when the command button is pressed the macro should execute the following:
1. Search for the Product ID in Sheet 1 from Sheet 2, if it finds it in Sheet ,
It will only change the Amount found on Row 3 in Column C in Sheet 1 with the Amount on Sheet 2 and Column F. The output result of how it should look is shown below
2. If it does not find a Product ID in Sheet 1 that is found in Sheet 2, it should add it in Sheet 1 in Ascending order and have the same format in Sheet 1.
3. If it finds a Product ID in Sheet 1 that is not in Sheet 2, it should delete the corresponding rows. That is ONLY the first two rows connected to every Product ID
4. If it finds a Product ID in Sheet 1 and Sheet 2 with the same amount, it should not alter it (move to next)
Sheet 1
Product IDColor/TypeAmount
10001White
Cotton1000
10003Blue
Cotton1500
10004Black
Cotton4500

<tbody>
</tbody>













Sheet 2

A-------------------B--------------C-----------D----------E------------F-------
10001White50050010002000
10002Purple18009003003000
10003Blue1500001500
10004Black210025016504000

<tbody>
</tbody>







Output result = Notice that the Word Cotton does not change even with a new product id added
You will also notice that the Amounts replaced are from Column F
Product IDColor/TypeAmount
10001White
Cotton2000
10002Purple
Cotton3000
10003Blue
Cotton1500
10004Black
Cotton4000

<tbody>
</tbody>
 
Last edited:

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,215,562
Messages
6,125,546
Members
449,237
Latest member
Chase S

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