I should be able to get my head round this but have a complete mental block. Im trying to write an algorithim and then a vba user defined function to solve the following problem:

I have N (max 32) display panels and each panel can have any one of R (say 4) layout configurations. I want to write a code which will output an array of N columns with each row populated with the Layout number (I've used letters for clarity only):

For example a 3 panel situation would output

AAA
AAB
AAC
AAD
ABB
ABC
ABD
ACC
ACD
ADD
BBB
BBC
BBD
BCC
BCD
BDD
CCC
CCD
CDD
DDD

I know the maths to work out the number of non repetetive combinations - its the logic of generating the aray table which has defeated me.

Any help would be gratefully received.

Thanks in anticipation