This page is part of the 33 lessons from the
Tutorial on VBA for Excel (Macros)
VBA for Excel made simple
VBA Section 2: Coding in VBA for Excel
This website is divided in 3 sections. Here are the topics of the second section on the VBA code.
This section is about coding (writing sentences so that Excel understand). The rules are not as severe as in other programming languages and VBA is very forgiving usually telling you that there is something wrong in your code as soon as you click on enter. In these lessons you will learn a lot of tips to make things easier in "General Coding Tips" and then you will discover the limited vocabulary of Excel. A ordinary sentence for Excel is more like "Me.Hungry, Me.Thirsty" than "My stomach is telling me quite clearly that it is time for me to start thinking about eating and drinking".
Lesson 2-1: Code in VBA for Excel
A few tips to make things easier when you start coding.
Lesson 2-2: Dealing with
Errors
VBA tells you when the code is wrong but what if the logic is wrong or what if the user gives a wrong answer.
Lesson 2-3: Code for the Application
Among the objects that you will be working with is Excel itself. It is called the APPLICATION.
Lesson 2-4: Code for the Workbooks
Working with one workbook, with THISWORKBOOK, with many workbooks and even with all the workbooks in a directory.
Lesson 2-5: Code for the Worksheets
Moving from one to the other, copy/paste from one to the other, adding and deleting worksheets and even doing something on all of them.
Lesson 2-6: Code for the Columns, Rows, Cells and Ranges
Showing you how to travel within a worksheet and work with cells, rows and columns.
Lesson 2-7: Code for Message and Input Boxes
Interacting with the user with minimal effort.
Lesson 2-8: Code for Excel Database and Filters
Most of your data in the form of a database. Learn how to sort and filter your data.
Lesson 2-9: Code for Statements
They are the KILL, the IF_THEN_ELSE_END, the SELECT-CASE, the DO_LOOP, the FOR_NEXT....
Lesson 2-10: Code for Functions
Creating new Excel functions, using the Excel functions in VBA and a few VBA functions.
Lesson 2-11: Code for Variables
When you don't want to hard code things and when the value of something changes put it in a variable. Discover the VARIANT type variable that allows you to execute 1,000,000 calculations in less than 5 seconds.
Lesson 2-12: Code for external data and SQL
When you connect to outside sources of data (large databases, text files, other Excel workbooks, Access, etc.) the computer is using SQL (Structured Query Language) a specialized language to work with data. You can use Excel's functionalities to connect and extract data but you can also use directly the SQL language. It is much faster.
Lesson 2-13: Code for Windows, other Microsoft Programs and APIs
With VBA for Excel you can develop procedures (macros) to work in Excel. Using the API functions you can also program things in WINDOWS from Excel.
|