Getting Started With Excel and VBA in the Laboratory:Resource Page
From LabAutopedia
Resource page for the "Getting Started With Excel and VBA in the Laboratory" short course
To be taught at the SLAS LabAutomation2011 conference, January 2011
Contents |
Synopsis
This course is designed to help laboratory scientists take Microsoft Excel to the next level by learning how to customize and automate its behavior. The primary tool that is used for this customization is the Visual Basic for Applications (VBA) progamming language, embedded within Excel. Attendees of this short course will learn the VBA language from the beginning, with a particular emphasis on solving problems commonly encountered in the laboratory.
Numerous topics will be covered over the course's two days. The VBA programming language and Visual Basic Editor will be introduced progressively using numerous exercises. Excel's internal objects will be explored in detail with relevant examples. Various methods for customizing the Excel user interface will also be demonstrated and tested. Finally, you will find out how to pack up and distribute your custom scripts for others to use. Laboratory related problems involve custom data loading, processing and visualization techniques.
Computers and software will be provided. Although, you are welcome to bring your laptop with Excel 2007 installed.
Instructors
| William Neil Princeton, NJ | Martin Echols Yardley, PA |
Detailed Course Outline
- Introduction
- What is Visual Basic for Applications (VBA)?
- What can you do with VBA?
- Reading Files Into Excel
- Text Versus Binary Files
- ASCII Encoding
- Text File Format Terminology
- Example 1: Opening Text Files
- Example 2: Opening Delimited Files
- Example 3: Opening Fixed-Width Files
- The Macro Recorder
- The Visual Basic Editor
- Example 4: Record a Macro
- Macros, Subroutines and Functions
- VBA Variables
- Data Types
- Variable Declarations
- Assignments
- Objects
- Understanding Object Oriented Programming
- Object Properties
- Object Methods
- Example 5: Using Objects to Improve a Recorded Macro
- Example 6: Further Improving a Recorded Macro
- Example 7: Testing the New Macro
- The Excel Object Hierarchy
- Learning the Excel Object Model
- The Range Object
- The Immediate Window
- Getting Values from Cells
- Putting Values into Cells
- Example 7: Directly Copying Data Between Cells
- String Manipulation
- Data Conversion Functions
- Example 8: Convert Well to Row / Column
- Looping
- Example 9: Use Well Label to Copy Data
- Application Object
- Getting a File Name
- Example 10: GetOpenFileName
- Files
- Opening Files
- Closing Files
- Reading Files
- Writing Files
- Creating a Log File
- Example 11: Read Lines from a File
- Arrays
- Splitting String into Arrays
- Example 12: Read Data From the File
- Example 13: Parse a File Header
- Array Bounds
- Rounding Numbers
- Example 14: Multiple Measurements
- Cell Formatting
- Adding Cell Comments with VBA
- Colors in Excel
- Setting Cell Colors with VBA
- Example 15: Cell Formatting with VBA
- Handling Runtime Errors
- Example 16: Handling Errors
- Variable Scope, Visibility and Lifetime
- Visibility Examples
- Customising Excel's User Interface
- Example 17: A Custom Menu
- Example 18: Processing Multiple Files at Once
- Custom Add-Ins
- Setting Project Properties
- Protecting the Add-In
- Saving the Add-In
- Testing the Add-In
Sample Course Video Clip
Related LabAutopedia articles
| Programming Automation | List_of_programming_and_computer_science_terms |
| A very basic overview of TCP/IP communications | Electronic interfaces |

