VBA: cut/paste orders into different files based on common/duplicate IDs

rubyb

New Member
Joined
Mar 26, 2014
Messages
18
Hi all,

I am very new to VBAs and macros and am not quite comfortable with them, but a new school project requires their use (I think!). I have looked at many other threads posing similar questions, but none of the solutions seem to fit my needs...

This is the deal: my project requires me to look at raw data and automatically have it sort into different files based on if there is is a duplicate entry in a specific column. This is an example of the raw data (dummy data and titles); assume that it is in a file called "raw data.xlsx":
[TABLE="width: 500"]
<tbody>[TR]
[TD]Order date [/TD]
[TD]Expected delivery[/TD]
[TD]Product[/TD]
[TD]Product code[/TD]
[TD]Price$[/TD]
[TD]Quantity[/TD]
[TD]Total[/TD]
[TD]Buyer ID[/TD]
[/TR]
[TR]
[TD][TABLE="width: 65"]
<!--StartFragment--> <colgroup><col width="65" style="width:65pt"> </colgroup><tbody>[TR]
[TD="class: xl63, width: 65, align: right"]14-09-01[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 65"]
<!--StartFragment--> <colgroup><col width="65" style="width:65pt"> </colgroup><tbody>[TR]
[TD="class: xl63, width: 65, align: right"]14-09-07[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]98476[/TD]
[TD]BETAx303[/TD]
[TD]1200[/TD]
[TD]12[/TD]
[TD]12400[/TD]
[TD][TABLE="width: 65"]
<!--StartFragment--> <colgroup><col width="65" style="width:65pt"> </colgroup><tbody>[TR]
[TD="width: 65"]123ZXY[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]14-09-04[/TD]
[TD]14-09-10[/TD]
[TD]34876[/TD]
[TD]ZETAq4[/TD]
[TD]1000[/TD]
[TD]14[/TD]
[TD]1400[/TD]
[TD]678TUV[/TD]
[/TR]
[TR]
[TD]14-09-04[/TD]
[TD]14-09-10[/TD]
[TD]34877[/TD]
[TD]WARK3[/TD]
[TD]875[/TD]
[TD]35[/TD]
[TD]30625[/TD]
[TD]678TUV[/TD]
[/TR]
[TR]
[TD]14-09-10[/TD]
[TD]14-09-15[/TD]
[TD]18983[/TD]
[TD]BETA304[/TD]
[TD]500[/TD]
[TD]47[/TD]
[TD]23500[/TD]
[TD]432LKN[/TD]
[/TR]
[TR]
[TD]14-09-19[/TD]
[TD]14-09-20[/TD]
[TD]58302[/TD]
[TD]NOVAs21[/TD]
[TD]1500[/TD]
[TD]15[/TD]
[TD]22500[/TD]
[TD]987EWW[/TD]
[/TR]
[TR]
[TD]14-09-19[/TD]
[TD]14-09-20[/TD]
[TD]58305[/TD]
[TD][TABLE="width: 65"]
<tbody>[TR]
[TD]ZETAqa[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]1000[/TD]
[TD]19[/TD]
[TD]19000[/TD]
[TD]987EWW[/TD]
[/TR]
[TR]
[TD]14-09-20[/TD]
[TD]14-09-28[/TD]
[TD]20394[/TD]
[TD]BLOMz1[/TD]
[TD]2000[/TD]
[TD]9[/TD]
[TD]18000[/TD]
[TD]567ABC[/TD]
[/TR]
[TR]
[TD]14-09-21[/TD]
[TD]14-10-01[/TD]
[TD]98477[/TD]
[TD][TABLE="width: 65"]
<colgroup><col width="65" style="width:65pt"></colgroup><tbody>[TR]
[TD="width: 65"][TABLE="width: 65"]
<tbody>[TR]
[TD]ZETAq4[/TD]
[/TR]
</tbody>[/TABLE]

[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]1000[/TD]
[TD]25[/TD]
[TD]25000[/TD]
[TD]302WLU[/TD]
[/TR]
</tbody>[/TABLE]


So what I need to do is to have a macro be able to identify if there are any duplicates in Column H/Buyer ID, and then have this row be cut and pasted (NOT simply copied and pasted) into another file, called "Multiple orders.xlsx". Essentially the point of the project is to be able to identify if any buyers are making more than one purchase per order.

I know how to do this manually, i.e.: find duplicates with conditional formatting and then cut/paste manually. However, I want to be able to automate this so that time is saved and the chance of errors is reduced.

Please let me know if something doesn't make sense… Any help would be much appreciated!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,223,718
Messages
6,174,082
Members
452,542
Latest member
Bricklin

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