# 1# 1 VBA Objects, Message Boxes as Functions What is an object in VBA? How do you move between design mode and run mode? How can you make a cell become.

Slides:



Advertisements
Similar presentations
Sep-05 Slide:1 VBA in Excel Walter Milner. Sep-05 Slide:2 VBA in Excel Introduction VBA = Visual Basic for Applications Enables end-user programming In.
Advertisements

1 Overview Introduction to VBA The Visual Basic Editor (VBE) –First Program Getting Started with VBA –Subroutines –Declaring variables –Input boxes and.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Excel Project 4 Financial Functions, Data Tables, Amortization Schedules, and Hyperlinks.
Creating New Financial Statements In Excel Presented by: Nancy Ross.
Lesson 4 Study Guide Review Microsoft Office 2003.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Using Macros and Visual Basic for Applications (VBA) with Excel
Developing an Excel Application
Tutorial 8: Developing an Excel Application
XP New Perspectives on Microsoft Excel 2003, Second Edition- Tutorial 8 1 Microsoft Office Excel 2003 Tutorial 8 – Developing an Excel Application.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Excel and VBA Creating an Excel Application
Microsoft Excel 2010 Chapter 8
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Visual Basic for Applications (VBA) An object-oriented programming language –Instructions for the manipulation of objects –A structured way to provide.
Lab 8 Solver In VBA ► Review – Solver Add-in In Excel ► Solver Add-in In VBA.
Spreadsheets in Finance and Forecasting Presentation 11 Visual Basic.
VBA – Visual Basic for Applications Week 20 - Tutorial.
University of Toronto at Scarborough © Andria Hunter, Kersti Wain-Bantin CSCA01 VBA-3 1 Lecture Outline Variable Scope Calling another subprogram Programming.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #4: Working with Variables and User Interfaces IE 212: Computational Methods for Industrial Engineering.
VBA for Excel. What is a spreadsheet? u An Excel spreadsheet is a set of worksheets  Each worksheets is made up of rows and columns of cells  Rows are.
IN THE NAME OF ALLAH UserForms on VBA Lab 06 Tahani Al_dweesh.
Introduction on VBA Lab 05 ins.Tahani Al_dweesh. Lab Objectives Introduction Calculation with VBA Storing and Retrieving Variables in a Worksheet Using.
Week 8.  Recap  User Forms  Input Validation Message Boxes Input Boxes  Conversion Functions.
University of Toronto at Scarborough © Andria Hunter, Kersti Wain-Bantin CSCA01 VBA 1 Lecture Outline Record macro and examine VBA code VBA Editor (IDE)
Week 3.  Assessed Exercise 1  Working with ranges.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
Info copied from Microsoft Help Files Excel: Introduction Microsoft Office 2003.
1 Performing Spreadsheet What-If Analysis Applications of Spreadsheets.
VBA Lab 2 I ns.Samia Al-blwi. Visual Basic Grammar Object: Visual Basic is an object-oriented language. This means that all the items in Excel are thought.
Course ILT Spreadsheet structure Unit objectives Enter labels and values; select a range; replace cell contents; undo or redo actions; and move, copy or.
# 1# 1 CS 105 Spring 2010 Macros: Sub Procedures You Record What is a macro? What is With…End With? What is Sub…End Sub? Relative vs. Absolute.
CHAPTER FIVE Specifying Alternate Courses of Action: Selection Statements.
Excel 2010 Formatting Columns and Rows Excel 2010 / Mr. Bitenas In this lesson you will learn how to insert, delete, and resize Columns and Rows.
Chapter 9 Macros And Visual Basic For Applications.
INSERT BOOK COVER 1Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Getting Started with VBA for Microsoft Office 2010 by.
# 1# 1 Using Procedures and Functions What is a procedure? What is a sub procedure (subroutine)? Built-in functions in your code What is a function? CS.
OV Copyright © 2011 Element K Content LLC. All rights reserved.  Determine the Dialog Box Type  Capture User Input Creating an Interactive Worksheet.
Intermacs Form Download Excel Tutorial Pivot Tables, Graphic Tools, Macros By: Devin Koehl.
Macro’s Within excel. Most functionality can be driven from VBA VBA is the programming language that runs inside of excel. It uses visual basic as the.
ME 142 Engineering Computation I Input, Output & Documentation.
Lab 10. User Forms Design – Code Part ► Lab 9 Review ► Continue ‘Student Record’ Example ► A Car Loan Application.
Intermacs Form Download Excel Tutorial Pivot Tables, Graphic Tools, Macros By: Devin Koehl.
Visual Basic Objects / Properties / Methods PropertyAdjective ObjectNoun Part of the application Attribute MethodVerb Action to do something.
VBA Navigation, Conditionals, and Boxes. VBA Navigation.
Chapter 2: Excel Basics and Formatting Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
VBA Programming Functions and Decisions. If-Then-Else Structure used to consider alternatives If then --or-- If then Else End If.
Microsoft Excel Prepared by the Academic Faculty Members of IT.
1 After completing this lesson, you will be able to: Create charts using the Chart Wizard. Move, resize, and delete charts. Modify chart titles and add.
An electronic document that stores various types of data.
ME 142 Engineering Computation I Interacting with Spreadsheets.
Excel Tutorial 9th Grade FACS. Access Excel from the Start Menu.
Financial Information Management VB, VBA, VS, VSTO & VBE: Putting it all together Source: Excel VBA Programming by John Walkenbach.
© Stefano Grazioli - Ask for permission for using/quoting: Source: Excel VBA Programming by John Walkenbach.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Chapter 7 Creating Templates, Importing Data, and Working with SmartArt, Images, and Screen Shots Microsoft Excel 2013.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Chapter 8 Working with Trendlines, PivotTable Reports, PivotChart Reports, and Slicers Microsoft Excel 2013.
Day 2: MS Excel for Beginners Aniko Balogh CEU Computer & Statistics Center
The Advantage Series ©2005 The McGraw-Hill Companies, Inc. All rights reserved Chapter 12 Introducing Visual Basic for Applications Microsoft Office Excel.
CIS 338: Dialog Boxes Dr. Ralph D. Westfall April, 2011.
Excel Tutorial 8 Developing an Excel Application
Data Validation and Protecting Workbook
Developing an Excel Application
Even More VBA IE 469 Spring 2017.
Learning Excel Session 9 and 10 Dr. Chaitali Basu Mukherji.
Microsoft Excel 101.
Activate a range and manipulating activated range
Microsoft Office Excel 2003
Custom Forms with VBA in Excel In-Class Exercise #11
Presentation transcript:

# 1# 1 VBA Objects, Message Boxes as Functions What is an object in VBA? How do you move between design mode and run mode? How can you make a cell become the active cell? CS 105 Spring 2010

# 2# 2 Objects—in Excel: OBJECTS Objects represent program entities, or elements that the program manipulates. e.g. a Worksheet, a Chart a Command Button, a Range Objects have _PROPERTIES_ (such as caption, name) and _METHODS_ (such as select, delete, add, clear). We name objects and refer to them by their name.

# 3# 3 CS 105 Spring 2010 Naming convention for Objects Command button = cmd cmdExit Label = lbl lblHelpMessage Check box = chk chkReadOnly See your Course Guide

# 4# 4 Excel CS 105 Spring 2010 Click the Office button and then click on Excel Options. Excel displays the Excel Options dialog box.

# 5# 5 CS 105 Spring 2010 Cells Notation Cells(3,1).Value refers to R3C1 below Remember, row first, then column B3 is the same as Cells(3,2)

# 6# 6 CS 105 Spring 2010 Help on cell notation One way to identify a cell is through Cells notation: Range("B1").Value = 8 Range(“E2").Value = 8 Can also be written: Cells(1,2).Value = 8 Cells(2,5).Value = 8

# 7# 7 CS 105 Spring 2010 Properties and Methods Properties Range("A1:A10").Value = 99 The Value property is what the cells hold, in this case 99 Methods We can use Range(“A1”).Select This makes “A1” the active cell

# 8# 8 How to you make Cells (1, 1) become the active cell? A. Click on Cell A1 B. In your code, write Range(“A1”).Select C. In your code, write Range(“A1”).Activate CS 105 Spring 2010

# 9# 9 Clearing a column You can clear a column using the ClearContents method: Private Sub cmdClear_Click() Range("D:D").ClearContents End Sub Note: ClearContents does not clear the formatting, just the numbers or formulas contained within the cells. What code would you use to clear the contents of a range?

# 10 CS 105 Spring 2010 Getting Feedback

# 11 CS 105 Spring 2010 Using the Message Box as a Function Just as we use the Input Box to get data, we can use the Message Box to gather data from the user

# 12 CS 105 Spring 2010 What is the difference? MsgBox "You are now leaving",, "Bye" Cells(1,2) Value = MsgBox(“Quit?”, vbYesNo, “Bye?”)

# 13 CS 105 Spring 2010 Using the Message Box to Get Data Private Sub cmdTaxi_Click() Cells(2,2).Value = MsgBox("Hello", vbYesNo, _ "Do you want a taxi?") If Cells(2,2).Value = vbYes Then Range("A1").Value = "Yes" End If If Cells(2,2).Value = vbNo Then Range(“B1").Value = "No" End If End Sub

# 14 CS 105 Spring 2010 The Message Box Also Returns a Number Private Sub cmdNumber_Click() Cells(3,2).Value = __ MsgBox("Make a choice", vbYesNo, " Yes or NO? " ) End Sub

# 15 CS 105 Spring 2010 vbOK, vbCancel, etc. vbOK 1 vbCancel 2 vbAbort 3 vbRetry 4 vbIgnore 5 vbYes 6 vbNo 7 The Message Box buttons return a value that can be used in programming. 1 2

# 16 CS 105 Spring 2010 To Summarize: What is an object in VBA? How do you move between design mode and run mode? How can you make a cell become the active cell?

# 17 You are so Right!!!! CS 105 Spring 2010