Thread: Loops
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default 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