开发者

Excel - Macro to compare /match multiple cells in a row between two sheets, and copy the entire row to the second sheet

开发者 https://www.devze.com 2023-02-25 03:50 出处:网络
i\'m looking for macro to match multiple cells in a row between two sheets, and copy the entire matched row from the first sheet to place beside the matched row from the second sheet.

i'm looking for macro to match multiple cells in a row between two sheets, and copy the entire matched row from the first sheet to place beside the matched row from the second sheet.

Below are excerpts of my excel worksheet:

worksheet A:

    E       F   H          J

2878 3/1/2011 Cash 1/3/2011_BSJ 636

worksheet B:

   A      C        E   F

50 1-Mar-11 DEP_CASH 636 TRAX_BRH_BSJ

For example if F2878 (row no. 2878, column F), E2878, J2878, H2878 of worksheet A = C50, A50, E50, F50 of worksheet B then copy whole 2878 row of worksheet A to I50 of worksheet B. Then strike through the 2878 row from worksheet A to indicate work done of a row. Note that some of the content might not exactly the same, 开发者_运维问答like F2878 contains "Cash" & C50 contain "CASH" out of "DEP_CASH" which are considered matched. I need to match some 3000+ row. Please help...


The problem is that the lookup-functions do only consider a single key column. So what I did on a similar problem is to add a single key column using some formula to concatenate the key parts with some special character, and then use a lookup-formula. As you have to create matching keys on both sides, you have a chance in the formulas building them to unify the texts. E.g. use uppercase to make sure they are spelled the same. Or just cut the word CASH out of a column...

Takes some trial and error... but as you can see the keys created, you can adopt your formula until it delivers the expected results.

(Depending on how complicated your matching logic is, something capable of handling regular expressions might help, e.g. Ruby, which is great at "remote controlling" Excel.)

0

精彩评论

暂无评论...
验证码 换一张
取 消