Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a project where I will have incoming order workbooks. The order
workbooks have UPC numbers and amounts. I want to write a script that will transfer the amounts from the "order workbook" to the "master workbook" by matching UPC numbers. The actual structure of the books is subject to change, so it cannot be a copy and paste. My first thought was to transfer the UPC range and the "amounts" range into arrays, then find each element of UPC range in the master book, and print the amount from the corresponding element in the "amounts range". Not sure if this would be the best approach. Any help would be appreciated. Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is there a reason not to use something like vlookup?
could the incoming workbooks have UPC's not in the master workbook. In any event, you approach of putting them into arrays should work. Not sure what you mean by help - what kind of help are you looking for. vArr = activesheet.Range("A1").currentRegion.Value for i = 2 to Ubound(vArr,1) res = application.Match(varr(i,1),Workbooks("Master.xls" ).Worksheets(1).Columns(1) if not iserror(res) then with Workbooks("Master.xls").Worksheets(1) .Cells(res,3) = varr(i,4) .Cells(res,5) = varr(i,2) end with end if Next -- Regards, Tom Ogilvy will put a table of data in an array. "AD108" wrote: I have a project where I will have incoming order workbooks. The order workbooks have UPC numbers and amounts. I want to write a script that will transfer the amounts from the "order workbook" to the "master workbook" by matching UPC numbers. The actual structure of the books is subject to change, so it cannot be a copy and paste. My first thought was to transfer the UPC range and the "amounts" range into arrays, then find each element of UPC range in the master book, and print the amount from the corresponding element in the "amounts range". Not sure if this would be the best approach. Any help would be appreciated. Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks very much,
I can work with this. Vlookup, at least hardcoded into the sheets, won't work due to cells being cleared after certain events. "Tom Ogilvy" wrote in message ... Is there a reason not to use something like vlookup? could the incoming workbooks have UPC's not in the master workbook. In any event, you approach of putting them into arrays should work. Not sure what you mean by help - what kind of help are you looking for. vArr = activesheet.Range("A1").currentRegion.Value for i = 2 to Ubound(vArr,1) res = application.Match(varr(i,1),Workbooks("Master.xls" ).Worksheets(1).Columns(1) if not iserror(res) then with Workbooks("Master.xls").Worksheets(1) .Cells(res,3) = varr(i,4) .Cells(res,5) = varr(i,2) end with end if Next -- Regards, Tom Ogilvy will put a table of data in an array. "AD108" wrote: I have a project where I will have incoming order workbooks. The order workbooks have UPC numbers and amounts. I want to write a script that will transfer the amounts from the "order workbook" to the "master workbook" by matching UPC numbers. The actual structure of the books is subject to change, so it cannot be a copy and paste. My first thought was to transfer the UPC range and the "amounts" range into arrays, then find each element of UPC range in the master book, and the amount from the corresponding element in the "amounts range". Not sure if this would be the best approach. Any help would be appreciated. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
array question | Excel Discussion (Misc queries) | |||
Array question | Excel Programming | |||
Array Question I think | Excel Programming | |||
Array question | Excel Programming | |||
vba array question | Excel Programming |