Thankfully Excel has a few "hidden" features that can take away some of the hassle and make the whole process a lot easier.
The Solution
This solution is pretty straight forward and we have created a little example spreadsheet to demonstrate how it is done. You can download the example file containing both the form and the code here.Open up the spreadsheet and launch the macro.



When the data is filled out, the form should look like this:



How it Works
The code behind this form is pretty simple and you can adapt it to your needs.All the work is done by one main subroutine
Sub JoinRanges(rngFirstRange As Range, lngFirstIdColumn As Long, rngSecongRange As Range, lngSecondIDColumn As Long, rngWriteResultTo As Range)This routine accepts the ranges, the id columns and the target range (where the data would be written).
For each line copied, the routine uses the match function to find the matching row in the second function:
Set rngColumn = rngSecongRange.Columns(lngSecondIDColumn) lngMatchingRow = WorksheetFunction.Match(varCurrentId, rngColumn, 0)Finally we copy the line from the second range (without the id column).
Summary
As you can see, our macro does all the heavy lifting for you. These kinds of repetitive data management tasks can be dramatically optimized with the right spreadsheets, we hope this shows one way your workload can be improved.About the author
Yoav Ezer co-authors the technology and productivity blog Codswallop. He is also the CEO of a company that produces PDF to XLS conversion software.For more Excel tips from Yoav, join him on Facebook or Twitter
0 comments:
Post a Comment