VBA - Remove only the first occurence of a duplicate based on a dropdown.

TriHard

New Member
Joined
Mar 9, 2017
Messages
9
Hi.
Hoping for some help on a VBA to remove only the first occurence of a duplicate.

Just a bit on my current setup;

This is essentially a goods out system.

Stock levels are held in the sheet "Stock" (A-Description, B-Product Ref, C-Supplier Barcode, D-Stock QTY).
The Stock sheet reads from another sheet, "Feed". Which is essentially just a counter which adds another row in once a barcode is scanned. It will add the Supplier Barcode into column B. Column A then has a Vlookup to reference that barcode in another sheet, "Barcode Library" where it matches the barcode to the product ref and pulls this through (into "Feed", A).

Back to the sheet "Stock". In Stock QTY (D) I have a CountIf to count the matching barcodes to give a stock quantity (example: A4 = Set of bearings | REF XXXXX | <barcode> | 5).
G3 has a dropdown which lists all of the Descriptions (column A). Once selected, G4 has a Vlookup to match the Product Ref (I did this as "Feed" has the Product Refs in column A).

I have a command button just below G7. The idea is that you would select your item from the dropdown (G3), hit the command button and it would delete the first match (of the Product Ref) over in Feed. Therefore reducing the Stock QTY by 1.

Unfortauntley I'm getting nowhere with the command button. Can anyone help? Absolute dream would be to have an additional box in G (ideally G5) where I could also add the quantity I need to book out and it would remove this many matches from Feed. If not I can keep to one by one as we don't book that many out (typically only 1 but can be more).

Any help on this would be greatly appreciated.

TIA
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I can't promise a solution but it would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach screenshots (not pictures) of your "Stock" and "Feed" sheets. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0

Forum statistics

Threads
1,224,742
Messages
6,180,684
Members
452,993
Latest member
FDARYABEE

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