Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Working With
Spreadsheets
CHAPTER OUTLINE
SPREADSHEET CONCEPTS
SPREADSHEET PROGRAMMING
DEVELOPING MACROS IN MS EXCEL
INTRODUCTION
Chapter Objectives
At the end of the chapter, the
student should be able to:
explain the theories behind
spreadsheet programs;
interface MS Excel with Visual
BASIC; and
write macros in MS Excel.
2
INTRODUCTION
Spreadsheets
A spreadsheet is an
interactive computer
application program for
organization, calculation
and analysis of data in
tabular form.
Spreadsheets developed
as computerized
simulations of paper
accounting worksheets.
INTRODUCTION
History of Spreadsheets
*Sometimes, you need to select Microsoft Office <Version> Excel Object Library
SPREADSHEET PROGRAMMING
Using Excel Object Model (cont.)
To start using Excel, type the following code at the beginning of the
code (before the form class statement):
Imports Excel = Microsoft.Office.Interop.Excel
You may replace the keyword Public with Dim if declaration would
be made inside the form class.
SPREADSHEET PROGRAMMING
Using Excel Object Model (cont.)
Example:
oSheet.Cells(8, 2).Value = Sample
Or
oSheet.Range(B8).Value = Sample
SPREADSHEET PROGRAMMING
Using Excel Object Model (cont.)
Example:
'Display Excel
oXL.Visible = True
With oSheet
'Directly type the values that we want
.Range("A1").Value = "Food"
.Range("A2").Value = "Transportation"
.Range("A3").Value = "Recreation"
.Range("A4").Value = "Total"
.Range("B1").Value = txtFood.Text
.Range("B2").Value = txtTransportation.Text
.Range("B3").Value = txtRecreation.Text
.Range("B4").Formula = "=Sum(B1:B3)"
VBA
The Windows version of Excel supports programming
through VBA which is an implementation of VB6 and its
associated IDE.
Programming with VBA allows spreadsheet
manipulation that is difficult or impossible with standard
spreadsheet functions and techniques.
Codes are written directly using the Visual Basic Editor
(VBE), which includes a window for writing code,
debugging code, and code module organization
environment.
DEVELOPING MACROS IN MS EXCEL
VBA (cont.)
Running VBA in Excel
To access VBA in Excel, go to:
Developer Tab Click Visual BASIC Button.
DEVELOPING MACROS IN MS EXCEL
VBA (cont.)
The VBA IDE
1. Project Window
2. Code Window
Displays the linked Excel Objects and VBA Objects
Allows viewing and editing of codes of a
Allows navigation among various components of
particular selected VBA project component
the VBA project