ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loops (https://www.excelbanter.com/excel-programming/272038-re-loops.html)

Tom Ogilvy

Loops
 
in D5 put in
=sumproduct(Countif('[A.xls]Sheet1'!A:A,C4:C200))

for a total of items in B found in A

=Countif('[A.xls]Sheet1'!A:A,C4) in D5, then drag down the column for a
count of how many times the items in column C are found in workbook A.

Adjust the reference to workbook A to reflect the location/sheet where the
data to be searched is located.

Regards,
Tom Ogilvy



"Dave" wrote in message
...
Hi,

Could some one please advise me on how to go about the following:

I have two Excel files - A:: a list of products, and B:: the products

that
each customer has ordered.

So what I would like to do would be to have a macro that would go through
sheet B ( column C4 to the end) and then find that item in file A, then
keep a total of how many of that item has been found.

Pseudocode for this would be as follows:

foreach item in File B ( in column C4 to end)
found = false;

foreach item2 in File A ( in column A1 to the end)

if( item == item2){

Dx++; // x is the row that item2 has been found in
found = true;
}
}

if(!found){
msg("Error: Item " + item + " was not found" );
}

}


Thanks








All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com