08_Excel_VB - CSI1306F LECTURE8 (VBA...

Info icon This 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”
Image of page 1

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

View Full Document Right 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?
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.
Image of page 3

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

View Full Document Right 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. 
Image of page 4
Manipulating Excel Cells 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.
Image of page 5

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern