The menu "Tools / Macro" menu has three options of interest:
"Macros" is used to run, edit, create, delete Macro programs.
"Record New Macro" is used to record keystroke commands in a Macro program.
"Visual Basic Editor" is used to create macro programs made up of a mixture of Macro and Visual Basic commands.
The "Visual Basic Editor" has two modes: Object and Code. In object mode you view the normal spreadsheet. In code mode you view the code associated with the Workbook and Worksheet objects. Each Worksheet you have has a code module in which you can add your code. The Workbook (which includes all the Worksheets) has its own module. You can add your own code modules which are independent of the Workbook and Worksheets modules.
The Macro code in these modules is made of Macro and Visual Basic commands. Macro commands perform the same result as using keyboard and menu options on the spreadsheet. Visual Basic commands duplicate some these Macro commands and perform many programming functions not possible with Macros alone.
Some code can be execute automatically when the Workbook is opened but that would be very limiting. You can also add many the following normal program Objects to your Worksheets from the Toolbox: Labels, Text Boxes, Push Buttons, Checkboxes, Option Buttons, List Boxes, Combo Boxes, Toggle Button, Spin Button, Scroll Bars, and Images. Each of these Objects is asscocated with Macro code in a module.
Code Modules are normally created and edited with the built-in "Visual Basic Editor" but you can import externally create code created with normal text editors such as Notepad. You use the menu item "File / Import File" to do this. Code Modules can also be saved to a normal text file by using the menu option "File / Export File". Even if the code is created outside Excel it still must be imported to be used.
If you have a particular type of program example in mind let me know and I will post it here or on my Web site.