Looking for a macro that copies data from two sheets based on a logic and pastes in third sheet

  • I have 100,000+ records in one sheet and 5000+ records in another sheet. I'm trying to achieve the below two tasks.


    1) The columns in sheet 1 are size (A), age (B), duration (C), sex (D), class (E), rating(F) and amount.(G) For each size, age, sex, class and rating the amount value differs. For example, for size 1, sex 1, class 1, rating 3 and age 18 the amount must be pasted in result tab in column c and for the same size 1, sex 1, class 1, rating 3 and age 19 the amount must be pasted in result tab in column D and for same criteria age 20 the amount must be pasted in column E and so on till age 99. There are multiple combinations of size, sex, class and rating for each age.


    2) The sheet2 has size(A), age(B), sex(C), class(D), rating(E) and amount(F) field. For each record that is pasted in the result tab, the value from this sheet must be copied and pasted in the result tab. The age in the sheet 2 starts from 38 to 99. For example , for size, 1, sex1, class 1, rating 3 and age 18 (the data that is pasted from sheet1), from sheet2 , amount starting form age 38 to 99 must be copied and pasted in column C of the result tab just after the amount for age 18 is pasted. For size, 1, sex1, class 1, rating 3 and age 19 (the data that is pasted from sheet1), the amount value starting from age 39 to 99 must be pasted in column D of result tab and for age20 in result tab, the amount value from age 40 to 99 must be pasted in result tab.


    I have attached sample excel with expected output. Thanks.