Microsoft Excel is a very well known spreadsheet application of Microsoft Corporation for Windows and Mac OS users. It features included calculation, graphing tools, pivot tables, and a macro programming language called Visual Basic for Applications (VBA).

MS Excel spreadsheet is a deep program rich in features and functionality. One of the most prevailing features of Excel is the ability to write programs that run “behind” your worksheets to turn excel into a calculation-oriented development platform for creating special-purpose spreadsheets, which can function as applications in their own right.

Good Tutorial on Excel Macros (VBA):

VBA (Visual Basic for Applications) is the programming language used within Excel to develop macros. It is a very user-friendly development environment.

Programmers of MS Excel can write code directly using the Visual Basic Editor (VBE), which includes a window for writing code, debugging and code module. The Visual Basic Editor is the user friendly program that you will use to talk with Excel. In VBE, you can create your VBA procedures (macros) and user forms. A common and easy way to generate VBA code is by using the Macro Recorder. The Macro Recorder records actions of the user and generates VBA code in the form of a macro.

Example: How to execute program of a workbook event in Excel VBA Programming??

Events: Events are actions performed by users, which trigger Excel VBA to execute a macro. Some examples of events are as follows —

  • The user double clicks a cell (worksheet event).
  • The user opens a workbook (workbook event).
  • The user changes the content of a cell on the sheet (worksheet event).

The following steps need to be follow when creating a workbook event:

1. Open the Visual Basic Editor (VBE).

2. Double click on this Workbook in the Project Explorer. The code window will appear showing you two drop-down lists.

3. Choose Workbook from the left drop-down list.

4. The right drop-down list shows you all the workbook events (don’t worry, you will never use most of these events). Choose the Open event. Excel VBA automatically places a Sub procedure for you.

5. Now you can add a line which will only be executed by Excel VBA when you open the workbook! Add the line: Suppose that you add a line MsgBox “Good Morning”

workbook event code

6. Close the Excel file (don’t forget to save).

7. Open the Excel file and test the workbook event.

Result shown as:

workbook event

Important Note: Security settings should be “ON”: its enable all macros.

Assignmenthelp.net – A leading global E-learning web-portal world-wide and provide a wide range of quality online programming help services to USA, UK, Australia, UAE and Canadian students. We provide Programming Assignment Help, Programming Language Help, VBA Excel Programming Help, VBA Programming, Excel Macros (VBA) Tutorials, Excel VBA Programming help for K-12, College and University level students.

You can find more information about Excel VBA Programming Help services, you can chat with one of our online helpers or click here to Contact Us.

Share