arrays - EXCEL VBA Copy certain columns from seperate workbook if they have matching string -


so i'm working on project has on 300 entries, these 300 pulled master workbook has 1000+. each have there own unique registration im looking vba if registration workbook 300 entries can found in masterwork book copy master smaller one. had been in order of done quite due them being in different orders can't figure out.

here's have far, i'm trying use arrays, if array value found in master copy, isn't working out me :(..

dim owb workbook dim test1(500) string, test2(500) string, test3(500) string, test4  (500) string    application .displayalerts = false .screenupdating = false .enableevents = false end   fpath = "\work\new location\mastercars.xlsx" 'file location  set owb = application.workbooks.open(fpath) 'open file = 1 500 'for each        test1(i) = thisworkbook.worksheets("carlist").cells(i, 1).value     test2(i) = thisworkbook.worksheets("carlist").cells(i, 8).value     test3(i) = owb.worksheets("sheet2").cells(i, 1).value     test4(i) = owb.worksheets("sheet2").cells(i, 2).value 'declare locations      if test3(i) = test1(i)         test2(i) = test4(i)     end if next 

thanks

since unordered, need 2 loops testing. don't need array, can test values directly cells, , must set them cells (setting values array changes nothing on sheet).

dim master worksheet dim slave worksheet  'please verify if master , slave correct here set master = owb.worksheets("sheet2") set slave = thisworkbook.worksheets("carlist")  = 1 500 '(the slave sheet)    j = 1 5000 '(the master sheet)        if master.cells(j,1).value = slave.cells(i,1).value            slave.cells(i,8).value = master.cells(j,2).value        endif    next next 

never forget turn screen updating true, or not able use excel after , not see inserted data properly.

you don't need disable alerts , events, make no difference. screen updating can make code slow, it's useful disable it.


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -