Hi Jietoh,
If I understand the problem correctly, you want to import monthly data into a yearly report. If you know a few tricks, sorting the data is not needed. See the attached file which contains the code below. This should help you get started.
Assumptions and Pseudo Facts:
a. Sheet 'Yearly Report' contains simulated yearly data per your example.
b. Sheet 'Monthly Report' contains simulated monthly data per your example.
c. I assumed column 'B' (Data2) and Columm 'C' (Data4) were to be imported from the Monthly Report into the Yearly Report.
d. Account Numbers were in Column 'A' of both Sheets.
How the Software Works:
a. The Yearly Report Columns for 'Data2' and 'Data4' are cleared.
b. Created a list (Scripting Dictionary) of all the Account Numbers in the Monthly Sheet. This will fail after approximately 10,000 to 20,000 different Account Numbers. Each Account Number is stored with it's associated Row Number on the Monthly Report.
NOTE: Account Numbers must be UNIQUE on the Monthly Report
c. Each row of the Yearly Report is processed.
d. If the Account Number for a Yearly Report row is in the Dictionary, 'Data2' and 'Data4' are read from the Monthly Report and put into the Yearly Report.
In ordinary code module such as ModMonthlyIntoYearly or Module1:
Lewis
Bookmarks