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.

Slides:



Advertisements
Similar presentations
ADO DB in Access VBA © Walter Milner 2005 Slide: 1 ADO VBA Programming in Access.
Advertisements

Slide 1 Insert your own content. Slide 2 Insert your own content.
Lists, Loops, Validation, and More
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5- 1 STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
1 VBA Introduction. Basic Components 2 VBA LANGUAGE OFFICE OBJECTS EXCEL OBJECTS ACCESS OBJECTS WORD OBJECTS OUTLOOK OBJECTS POWERPOINT OBJECTS.
Excel Object Model.
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
1B40: Data analysis 1 Objects Visual Basic is an (OO) object-oriented language. Performing a task in Visual Basic (VB) or.
1 After completing this lesson, you will be able to: Use the Formatting toolbar to format text. Apply character effects to text. Align text. Cut and paste.
Pasewark & Pasewark Microsoft Office 2003: Introductory 1 INTRODUCTORY MICROSOFT EXCEL Lesson 2 – Changing the Appearance of a Worksheet.
David Walker Ottawa TMG Users Group 15 March 2014.
1 Overview Introduction to VBA The Visual Basic Editor (VBE) –First Program Getting Started with VBA –Subroutines –Declaring variables –Input boxes and.
Visual Basic for Applications (VBA) An object-oriented programming language –Instructions for the manipulation of objects –A structured way to provide.
Addition 1’s to 20.
Test B, 100 Subtraction Facts
Week 1.
Excel Lesson 15 Working with Auditing and Analysis Tools Microsoft Office 2010 Advanced Cable / Morrison 1.
Creating a User Form. A Better Interface Our programs can use input boxes for input and write on the spreadsheet page for output This works ok but is.
Excel and Visual Basic. Outline Data exchange between Excel and Visual Basic. Programming VB in Excel.
MS-Excel XP Lesson 2. Handling Worksheets 1.Bottom of the every workbook you can get worksheets. 2.No of sheets for a book is three. But you can add,
Modeling using VBA. Covered materials -Userforms -Controls -Module -Procedures & Functions -Variables -Scope.
Essence of programming  Branching  Repetitions.
Visual Basic for Applications. What it does Extends the features and built in functions of Excel – Create and run VB procedures – Some may be easy to.
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
Tutorial 12: Enhancing Excel with Visual Basic for Applications
VBA for MS Excel Hamze Msheik. Open the Visual Basic Editor in Excel 2007 Click on the Microsoft Office button in the top left of the Excel window and.
How to get started with Excel VBA. We need to enable programming in Excel  the “Developer menu”
Excel and VBA Creating an Excel Application
VBA Programming Session #2. Things to Review  Variables  Procedures: Subs & Functions  If…Then  For…Next.
VBA & Excel Barry L. Nelson IEMS 465 Fall Quarter 2003.
Visual Basic for Applications (VBA) An object-oriented programming language –Instructions for the manipulation of objects –A structured way to provide.
Macros n Macros are little programs that you can create to automate particular tasks that you may want to execute more easily than having to specify all.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
VBA (Visual Basic for Applications) What is Excel, just a spreadsheet? Time for Demos...
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.
# 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.
Introduction on VBA Lab 05 ins.Tahani Al_dweesh. Lab Objectives Introduction Calculation with VBA Storing and Retrieving Variables in a Worksheet Using.
Ch 11: Userforms CP212 Winter Topics Designing User Forms o Controls Setting Properties o Tab Order o Testing Writing Event Handlers o Userform_Initialize.
Introduction to VBA MGMI Aug What is VBA? VBA = Visual Basic for Application Excel’s powerful built-in programming language An event-driven.
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
Chapter 11: Introduction to the Visual Basic Environment Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
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)
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
Visual Basic for Applications Macro Programming For Microsoft Office.
Visual Basic for Applications (VBA) An object-oriented programming language –Instructions for the manipulation of objects –A structured way to provide.
Outline Software and Programming Program Structure Tools for Designing Software Programming Languages Introduction to Visual Basic (VBA)
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.
MS Visual Basic Applications Walter Milner. Event-driven programming Standard approach for GUIs Contrast with old character interfaces – program determines.
How to get started with Excel VBA. We need to enable programming in Excel  the “Developer menu”
Chapter 9 Macros And Visual Basic For Applications.
MS Visual Basic 6 Walter Milner. VB 6 0 Introduction –background to VB, A hello World program 1 Core language 1 –Projects, data types, variables, forms,
INSERT BOOK COVER 1Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Getting Started with VBA for Microsoft Office 2010 by.
Chapter 11: Introduction to VBA Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Introduction to Excel VBA UNC Charlotte CPE/PDH Series December 17, 2009.
© VBA JETPACK Introduction to VBA.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
VBA Excel Macro 1.Create a Macro: To create a macro in Excel VBA, Create a Macro: To create a macro in Excel VBA,Create a Macro: To create a macro.
The Advantage Series ©2005 The McGraw-Hill Companies, Inc. All rights reserved Chapter 12 Introducing Visual Basic for Applications Microsoft Office Excel.
Excel Tutorial 8 Developing an Excel Application
Microsoft Office Illustrated
Excel VBA Day 3 of 3 Tom Vorves.
أ.إسراء الطريقي أ. هاله الشملان , 102 تقن , المعمل الخامس
Custom Forms with VBA in Excel In-Class Exercise #11
Presentation transcript:

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 MS Office applications Formulae and macros OK for simple actions, but.. Advantages over formulae and macros: –Multiple nested if is easy –Loops easy –Debugging easy

Sep-05 Slide:3 VBA in Excel Getting started View..Toolbars..Control

Sep-05 Slide:4 VBA in Excel Add a button Click the button button Drag on sheet to create one

Sep-05 Slide:5 VBA in Excel Format it Right click on button Select properties Set as required Note distinction between name and caption

Sep-05 Slide:6 VBA in Excel Program it Right click button Select View code:

Sep-05 Slide:7 VBA in Excel Test it On Control Toolbox, click set square This toggles run/design Click the button

Sep-05 Slide:8 VBA in Excel Referring to cells Private Sub CommandButton1_Click() Dim x As Integer Dim y As Integer Dim z As Integer Dim result As Integer x = Cells(1, 2).Value y = Cells(2, 2).Value z = Cells(3, 2).Value result = x * y + z Cells(4, 2).Value = result End Sub

Sep-05 Slide:9 VBA in Excel The VBA Excel Object model Hierarchy of classes Use to refer to things in an Excel application Very large number of classes, properties and methods Have to use on-screen help for reference

Sep-05 Slide:10 VBA in Excel The VBA Excel Object model Object is a thing Property is some property of an object Method is something the object can be told to do Event is something that can happen to the object Collection is a set of related objects Enumeration is action returning complete set of things (eg all fonts on system)

Sep-05 Slide:11 VBA in Excel Example object - Application

Sep-05 Slide:12 VBA in Excel Example properties of Application Program a button which sets a value for this property and see what happens Try it in a loop for a bizarre effect

Sep-05 Slide:13 VBA in Excel Example method Program a button which calls the findfile method of the application

Sep-05 Slide:14 VBA in Excel Example collection - Display the count property of the worksheets collection in a msgbox to show how many sheets there are in the workbook

Sep-05 Slide:15 VBA in Excel Using For Each.. Next in a collection Private Sub CommandButton4_Click() Dim w As Worksheet For Each w In Application.Worksheets MsgBox (w.Name) Next End Sub

Sep-05 Slide:16 VBA in Excel The RangeSelection property of the ActiveWindow This is a Range object So it has the properties of a Range object Use them to program a button which displays the total of the numbers in the cells selected

Sep-05 Slide:17 VBA in Excel 2d array exercise Use the RangeSelection property to program a button which does a vertical flip of selected cells