Random Button Colour with Excel VBA

Creating a group of Active X command buttons and showing a different colour each time is a bit of a novelty but adds a bit of pizzazz to a procedure. To do so I will draw on a procedure demonstrated in the List Unique Items with VBA article. The procedure also draws on the colour of buttons in this article Colour Button on Click which isolates one colour. This procedure could be used inside that one using the different colours shown below. The following is a pictorial example of the procedure.

Each time the Blue button is clicked the colour of the buttons below will change. The first thing I need to do is to set up a table with the numbers which represent the above colours.

The table above is has Vlookup formula which changes based on the Random Number Generator. For the number generator there needs to be a start number (1) and an end number in this case 12. The following is the code for the main procedure;

The code loops through the data table above and re colours each command button based on the colour indicated by the table. This part of the code RGB(arr(i, 1), arr(i, 2), arr(i, 3)) is the reference to the tables 3 elements.