title: Group Number By Using Permutation and Combination in VBA Excel
body: <p>Suppose that we have <strong>N</strong> number or data and we want to put those number or data into a group that contains <strong>k</strong> number. For example: let <strong>A</strong> be a set of number {1, 2, 3} and I want to put them into groups that contains 2 number. If I use <a href="http://en.wikipedia.org/wiki/Permutation" rel="nofollow">permutation</a>, I will get {1,2}, {1,3}, {2,1}, {2,3}, {3,1}, and {3,2}. If I use <a href="http://en.wikipedia.org/wiki/Combination" rel="nofollow">combination</a>, I will get {1,2}, {1,3}, and {2,3}. I want each group is placed in different row and each number in different cells, for example: {1,2} in first row (<strong>cells(1,1) = 1</strong> and <strong>cells(1,2) = 2</strong>), and so on like the example below.</p>
  
  <hr>
  
  <p>1 | 2</p>
  
  <hr>
  
  <p>1 | 3</p>
  
  <hr>
  
  <p>2 | 1</p>
  
  <hr>
  
  <p>2 | 3</p>
  
  <hr>
  
  <p>3 | 1</p>
  
  <hr>
  
  <p>3 | 2</p>
  
  <hr>
  
  <p>How to make a VBA Excel program to do thing such that? </p>