Tag Archives: randomize

Use VBA to randomize cells in Excel

This is quick excursion into Excel VBA programming. This example uses a VBA macro to let you randomize the selected cells in an Excel workbook. If you select a contiguous block of cells and click the Randomize button, the following … Continue reading

Posted in Excel, Office, VBA | Tagged , , , , , , , , , , , , , | Leave a comment

Randomize two-dimensional arrays in C#

This example uses the following extension method to randomize two-dimensional arrays. // Randomize a 2D array. public static void Randomize<T>(this T[,] values) { // Get the dimensions. int num_rows = values.GetUpperBound(0) + 1; int num_cols = values.GetUpperBound(1) + 1; int … Continue reading

Posted in algorithms, extension methods, mathematics | Tagged , , , , , , , , , , | Leave a comment

Make extension methods that randomize arrays and lists in C#

This example uses the techniques described in the post Randomize arrays in C# to make extensions methods that randomize arrays and lists. Extension methods must be in a public static class. This example creates a RandomizationExtensions class. That class declares … Continue reading

Posted in algorithms, extension methods, mathematics | Tagged , , , , , , , , , , , | 1 Comment

Randomize arrays in C#

This example builds a Randomizer class that lets you randomize arrays. It provides a generic Randomize method that randomizes an array containing any kind of data. The following code shows the class. public class Randomizer { public static void Randomize<T>(T[] … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , | 7 Comments