Category Archives: VBA

Add and remove pictures in an Excel worksheet

This is another brief foray into VBA programming. When you click the Insert Image button, the following VBA code executes. ‘ Insert a picture at the selection. Sub Button1_Click() Dim filters As String Dim filename As Variant ‘ Define the … Continue reading

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

Use VBA code to pick random cells from the currently selected cells in an Excel workbook

This example shows how you can use VBA code to pick random cells in an Excel workbook. Sooner or later, many programmers need to write code to control another application such as the Microsoft Office applications, either for their own … Continue reading

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

Make a C# DLL and use it from Excel VBA code

This example shows how to make a C# DLL and then use it from VBA code running in Excel. A similar procedure should work for other Office applications. Note that some of the steps may require modification and significant fiddling … Continue reading

Posted in Excel, interoperability, Office, VBA | 10 Comments

Use VBA to randomize blocks of cells in an Excel workbook in C#

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

Posted in Excel, Office, VBA | Leave a comment