08_Excel_VB - CSI1306F ComputingConceptsforBusiness...

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

View Full Document Right Arrow Icon
CSI 1306 F “Computing Concepts for Business” LECTURE 8: “COMMUNICATING WITH THE WORKSHEET”
Background image of page 1

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

View Full DocumentRight Arrow Icon
Visual Basic for Applications (VBA) In the last lecture, we got introduced to the Visual Basic   (VB) programming language. In particular, we wrote programs using the built-in VB  editor that comes with Microsoft Excel as part of the Office  package. This variant of VB is known as VBA and it is meant to assist  users by providing extra functionality to the standard Office  tools (Word, Excel, PowerPoint, Access, OneNote, etc). For instance, what if we want to perform some calculations  using data from an Excel worksheet and none of the built-in  Excel functions meets our needs?
Background image of page 2
Excel Object Model (EOM) In that case, we may code (program) our own VBA module  that communicates with the worksheet.  Communication with Excel is possible through the  Excel  Object Model  (EOM). EOM is a collection of “objects” and “classes” offered by Microsoft  Excel to other programs so as to provide communication with it. In this lecture, we will learn how to use the main EOM  features in order to get data from any Excel worksheet,  process them using our own VBA module and output back  the results to the worksheet.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Main EOM Objects To communicate with Excel, we can use the following  objects provided by the Microsoft EOM: Worksheets : Gives access to the collection of worksheets in the current  workbook. e.g. Worksheets(1) is the first worksheet in our workbook. Worksheets(“Sheet3”) refers to the worksheet named “Sheet3” in our  workbook. If there is none, an error will be raised. Charts : Gives access to the collection of charts in the current workbook. e.g. Charts(1) is the first chart in our workbook. Cells : This is a property of any Worksheet object. By means of it, we can  get/set the value of any cell in any worksheet. 
Background image of page 4
Before accessing any cell value in Microsoft Excel, we must  make sure we know which worksheet that cell belongs to. e.g. there is a cell A3 is Sheet1 and also another A3 in Sheet3. Which  one do you mean? From any VBA program, we can eliminate the ambiguity on  which worksheet a cell belongs to if we “activate” the  worksheet before we start accessing any value on it. Worksheets(“Sheet1”).Activate And then we can access e.g. cell C4 in that worksheet. Dim x As Integer
Background image of page 5

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

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

This note was uploaded on 09/01/2010 for the course COMPUTER S CSI1306 taught by Professor Aziri during the Spring '10 term at University of Ottawa.

Page1 / 32

08_Excel_VB - CSI1306F ComputingConceptsforBusiness...

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

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