NotesOnVBA&Excel

NotesOnVBA&Excel - VBA: Visual Basic for...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 VBAIntro VBA: Visual Basic for Applications - Introduction What is VBA? VBA is a version of Visual Basic (VB) available in most Microsoft (MS) Office applications such as MS Excel, MS Word, and MS PowerPoint. A more limited version of VB, known as VBScript, is available in MS Access (the MS Office database application), as well as in MS Internet Explorer (the MS web browser). In MS Office applications VBA is used mainly to develop procedures, known as Macros , that can be run within the application itself. By using VBA within a given application you can use the application's own interface to run a program (a macro) rather than creating your own interface as you do when developing a VB program from scratch. For example, when using VBA within MS Excel we can use the Excel spreadsheet cells as input or output locations for a given numerical procedure. Other than that, programming a macro within MS Excel, or any MS Office application, for that matter, is not different than programming a sub procedure in VB. All the VB commands, such as Open, Close, Input, Print, If blocks, Do While, Do Until, For…Next, etc., are also available within VBA. Numerical solutions in MS Excel MS Excel is an excellent application for developing numerical solutions. Even without programming macros in the spreadsheet, you can solve many numerical problems by using the operations and functions already available in MS Excel itself. For instance, the examples on numerical solution of non-linear equations, numerical integration, and calculations of statistics of a sample, provided in earlier handouts, were developed using MS Excel. Considering that spreadsheet programs are commonly available, I expect that you have had a minimum amount of experience in using MS Excel (or other spreadsheet applications, e.g., Quattro Pro) including the production of tables, use of pre-defined functions, and creation of graphics. If you have not used MS Excel before, I would recommend that you learn its basic operation by following one of the many books on the subject available in any local bookstore. Some of those books may be available at the USU library for check out. My understanding is that those students that took Freshman Engineering seminar at USU have had experience with MS Excel or Quattro Pro spreadsheets. Therefore, I will be covering mainly the use of VBA within an MS Excel spreadsheet, rather than the operation of the spreadsheet per se. Combining MS Excel and VBA - An Example As indicated above, MS Excel worksheet cells can be used as input locations for a VBA program. Those input cells in the worksheet can be referenced within a VBA program (macro) by using the VBA functions Range and Cells . As an example of a simple VBA application within Excel, open an Excel worksheet and fill out the cells as shown in the figure below. The contents of cells A1 and A3 are simply strings that cover additional cells to the right. These strings are entered by clicking on the corresponding cell and
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/08/2010 for the course COT 3502 taught by Professor Hawkins during the Fall '08 term at University of Florida.

Page1 / 16

NotesOnVBA&Excel - VBA: Visual Basic for...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online