Programming Visual Basic in Excel

Visual Basic can be used with Excel to rapidly and easily construct spreadsheet programs that can be used for simulations, classroom demonstrations or other useful tasks.  This is a tutorial in how to program Visual Basic in Excel which will proceed through several small examples.  We will also give two examples of spreadsheet programs that may indicate the power of this programming language for creating simulations in Excel.

Here, we assume some familiarity with Basic (often the first programming language people are exposed to).  This is not meant to be an introduction to programming or a systematic introduction or reference to Basic, although enough of the language is shown through several examples that the reader might "catch on" or at least remember how things work.  It is also not meant to be an introduction to Excel.  (If you have used Excel to do such tasks as generate a histogram for a set of data, you should be ready to read this.)

Introduction

Section 1:  A "Hello World!" program.

Section 2:  Controlling the spreadsheet from a Visual Basic program.

Section 3:  Recording a macro.

Section 4:  Input and Output in Visual Basic.

Section 5:  Putting a command button into a spreadsheet.

Section 6:  A spreadsheet program that simulates coin tosses.

Section 7:  A spreadsheet program that generates nice random home prices.
 
 

Contents   Introduction  |  Sections  1  2  3  4  5  6  7