DW Faisalabad New Version

DW Faisalabad New Version
Please Jump to New Version
  • Working with Tables
  • While there are four types of database objects in Access, tables are arguably the most ... read more

    Monday, 10 July 2017

    Run Code from a Module

    As a beginner to Excel VBA, you might find it difficult to decide where to put your VBA code. The Create a Macro chapter illustrates how to run code by clicking on a command button. This example teaches you how to run code from a module.

    1. Open the Visual Basic Editor.

    2. Click Insert, Module.







    6. Select Cyan and click Run.



    Result:



    Note: code placed into a module is available to the whole workbook. That means, you can select Sheet2 or Sheet3 and change the background color of these sheets as well. The Add a Macro to the Toolbar program illustrates how to make a macro available to all your workbooks (Excel files). Remember, code placed on a sheet (assigned to a command button) is only available for that particular sheet..