Question : Pre populating excel rows based on variables

Hi there,

I am trying to build a model where I create a long list of combinations based on variables and patterns.

Currently I have been storing data in an excel file  
 
Current excel model
 
and am after advice as how to best automate the process.

Essentially I am doing the following
- Coming up with variables e.g. colour, type, town
- Establishing patterns e.g. new [colour] [type] in [town]

And I want a tool to automatically create every variation of the patterns I identify. For example if I have the following variables for [colour] and [town]

[color] = blue | black | red | orange
[town] = london | manchester | bristol

Then I have the following pattern:-
new [color] house in [town]

I need the results to look like

new blue house in london
new black house in london
new red house in london
new orange house in london
new blue house in manchester
new black house in manchester
new red house in manchester
new orange house in manchester
new blue house in bristol
new black house in bristol
new red house in bristol
new orange house in bristol

Any help would be greatly appeciated.

Answer : Pre populating excel rows based on variables

chocobogo,

My macro will work for any size range.  You do not need to know the dimensions before running.  I am having trouble downloading your file.  It comes in as a zip file and opens in a weird xml format.  I used the sheet names and ranges you placed in your first workbook.  If you press F8 it will walk you through the next line in the macro.  If you press it again it will allow you to go to the next line.  This should be helpful in you identifying where the code is breaking.  If the sheet names are a problem, or you want to change the names later, change the names in quotes to numbers such as 1, 2, etc....  When you are in the macro go to the Debug menu and look at the options.  F5 will run the whole program.  F8 allows you to walk step-in.

If you want to have 100, 1000, 10000, types this macro will work.  The Do While Loop does not appear to be the best structure for this problem.  I left my for loop in the comments.  As you can see it runs 1520 times.  I used this type of loop to figure out where to move the END row.  The code crashes if its not in the correct row because it runs infinitely/to excels limits and crashes the application.
Random Solutions  
 
programming4us programming4us