简体   繁体   中英

VBA to match across 2 tabs and multiple columns

Folks,

I have what should be a simple one, but I'm have few concerns about the performance.

I have a spreadsheet that gets data from a crystal report and uses that to derive some supplier information. If the date received is incorrectly entered into the source system we can unfairly "black mark" the supplier, so we update the data in the spreadsheet, but obviously this gets overwritten daily.

I have some code that archives off any updates, but after a refresh I'd like to put that back.

So, where Tab1.A$1 = Tab2.A$1 AND Tab1.A$2 = Tab2.A$2 AND Tab1.A$3 = Tab2.A$3 AND Tab1.A$4 = Tab2.A$4 AND Tab1.A$5 = Tab2.A$5 then I need to update Tab1.A$6 = Tab2.A$6

I could probably fathom this out, (I'm a DBA rather than a programmer), but the way I'd do it would involve looping through the Tab1 and then for each line loop through Tab2, swapping of tabs etc and is probably a very poor way of doing it. Is there a better way?

Cheers Mike

Just to understand this question correctly, can you please let me know if I am getting it right. As I understand you are foucusing on updating the 6th(rows that are different) row of a sheet to match the other sheet's 6th row if all other fields matches. Am I correctly understanding this ?

If So why don't you copy all the data from one sheet to another ?

From another point of view, if the tab to be updated consists of a subset of objets (say supliers), then it cannot be done in a static manner....

Can you please explain little more may be with an example ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM