Complex VBA to copy and paste based on 2 columns and different criteria

thedeadzeds

Active Member
Joined
Aug 16, 2011
Messages
442
Office Version
  1. 365
Platform
  1. Windows
Guys, not even sure if this is possible.

I have an excel table called 'Newport' which consists of the following 9 columns:


Dealer,
DecsR
Attempt - (this column will only consist of New, 1st, 2nd and 3rd)
RegNO,
Salute,
Updated,
Contdate,
Completecode


The table normally has around 2000 records. Is there a way to do the following:


Find The oldest 2 results based on 'Attempt' by each 'DescR' based on the oldest ContDate.

So out of the 2000 records copy 2 of each Attempt for each DescR to tab 'Blue'. If there is not 2 then copy what is there.

If this is possible, Is there a way to base the volume (ie 2 in this example) on whatever number is in cell a5 on the menu tab.


See expected results below: So in this we are showing the oldest New Calls based on contdate for Each DecsR, The oldest 1st based on contdate for Each DecsR, the oldest 3rd based on contdate for Each DecsR and so on

DealerDescRAttemptRegNoSaluteUpdatedcontdatecompletecode
BAASE1New Calls1Mr Jones 101/01/201801/02/2018CUA
BAASE1New Calls2Mr Jones 202/01/201802/02/2018CUA
BAASE11st3Mr Jones 303/01/201803/02/2018TEA
BAASE11st4Mr Jones 404/01/201804/02/2018CUA
BAASE12nd5Mr Jones 505/01/201805/02/2018LMS
BAASE12nd6Mr Jones 606/01/201806/02/2018CUA
BAASE13rd7Mr Jones 707/01/201807/02/2018CUA
BAASE13rd8Mr Jones 808/01/201808/02/2018CUA
BAASE2New Calls9Mr Jones 909/01/201809/02/2018CUA
BAASE2New Calls10Mr Jones 1010/01/201810/02/2018CUA
BAASE21st11Mr Jones 1111/01/201811/02/2018CUA
BAASE21st12Mr Jones 1212/01/201812/02/2018CUA
BAASE22nd13Mr Jones 1313/01/201813/02/2018LMS
BAASE22nd14Mr Jones 1414/01/201814/02/2018LMS
BAASE23rd15Mr Jones 1515/01/201815/02/2018CUA
BAASE23rd16Mr Jones 1616/01/201816/02/2018CUA
BAAPWBNew Calls17Mr Jones 1717/01/201817/02/2018CUA
BAAPWBNew Calls18Mr Jones 1818/01/201818/02/2018CUA
BAAPWB1st19Mr Jones 1919/01/201819/02/2018CCB
BAAPWB1st20Mr Jones 2020/01/201820/02/2018LMS
BAAPWB2nd21Mr Jones 2121/01/201821/02/2018CUA
BAAPWB2nd22Mr Jones 2222/01/201822/02/2018LMS
BAAPWB3rd23Mr Jones 2323/01/201823/02/2018LMS
BAAPWB3rd24Mr Jones 2424/01/201824/02/2018CUA
BAAPWSNew Calls25Mr Jones 2525/01/201825/02/2018CCB
BAAPWSNew Calls26Mr Jones 2626/01/201826/02/2018CUA
BAAPWS1st27Mr Jones 2727/01/201827/02/2018CUA
BAAPWS1st28Mr Jones 2828/01/201828/02/2018CUA
BAAPWS2nd29Mr Jones 2929/01/201801/03/2018LMS
BAAPWS2nd30Mr Jones 3030/01/201802/03/2018LMS
BAAPWS3rd31Mr Jones 3131/01/201803/03/2018LMS
BAAPWS3rd32Mr Jones 3201/02/201804/03/2018CUA

<tbody>
</tbody>
 
Last edited:

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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