Using a macro to populate rows based on several cells

Copper Contributor

Hi all, 

I'm quite new to all the vba possibilities so I hope that what I'm wishing for exists. 

Basically, I'd like to be able to populate rows with  some data based on a number that is on a cell. 

I'll use an example to be more understandable : 

 

We have this table that refers the number of items that are bought in each market. 

Market

Items
Sydney3
Melbourne2
Brisbane 4

 

Now, the situation is that every Item has a special number and they are all registered based on their market as well: 

Market Item NumberInformation x Information Y Information Z
SydneyITEM01   
SydneyITEM02   
SydneyITEM03   
MelbourneITEM04   
MelbourneITEM05   
Brisbane ITEM06   
Brisbane ITEM07   
Brisbane ITEM08   
Brisbane ITEM09   

(and we have many more items of course )

 

What we would like to do is to populate the second table automatically based on the numbers in the column 2 in the first table. (Like it is done in the 2nd table) Because here it was done manually but we would like to avoid that process. 

So basically, based on the number of items in table 1 (3 items for sydney for example), we'd like the macro to be able to pick 3 items number that are located in Sydney and paste them in another table (on another sheet).

 

As you can imagine we're working with bigger numbers and our numbers in column 2 in table 1 will always be different, which is why we would like that process to be automated. 

 

Does anyone has any idea on how to do this ? 

 

Feel free to ask questions, it's quite a tricky thing to explain, 

thanks for your help, 

Lau 

1 Reply

How do you know that Melborne is going to be ITEM04 and ITEM05 instead of ITEM06 and ITEM07?  In other words, do the item numbers always increment by 1 using the order of table 1?