See all How-To Articles

How to Generate All Permutations in Excel

This tutorial demonstrates how to generate all permutations in Excel.


generate permutations 5


Generate All Permutations

Using the VBA macro, you can generate all possible permutations of given characters. All you need is to create a small piece of code and enter input characters. To achieve this, follow the next steps.

  1. In the Ribbon, go to Developer > Visual Basic. If you don’t have this tab available, find out how to add the Developer tab.


generate permutations 1


  1. In the VBA window, go to Insert > Module.


generate permutations 2


  1. In the code window on the right side, paste the following code and save.


generate permutations 3a


  1. Now you have created the GetString macro, and you can run it. In the Ribbon, go to Developer > Macros.


generate permutations 3


  1. If it’s not already selected, select the macro, and click Run.


generate permutations 4


  1. In the pop-up window, enter characters for permutation (in this example, abcde), and click OK.


generate permutations 5


As a result, in Column A, you get all possible (120) permutations of entered characters.


generate permutations 6