Writing VBA Macros Record a new Macro, recording only the name, shortcut and description Stop recording Open macro for editing and enter VB code Test.

Slides:



Advertisements
Similar presentations
Review for Excel Chapter 1
Advertisements

Object Oriented Programming A programming concept which views programs as objects with properties and ways to manipulate the object and the properties.
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.
Using Macros and Visual Basic for Applications (VBA) with Excel
Developing an Excel Application
Excel Lesson 1 Excel Basics. Task 1  Goals  Learn about Excel  Start Excel  Explore the Excel screen  Explore the Excel workbook  Explore the worksheet.
Excel VBA Class Glenn Harris Microsoft Certified Trainer Office Master Instructor Excel Class NYC.
Macros Excel built-in functions are great but limited Macros are a means for the user to define new functions A macro is a single command that automates.
MS-Excel XP Lesson 8. Inserting and Formatting a Comment 1.Select cell or cell range 2.Insert menu, comment menu item 3.Type message to comment 4.Minimize.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
1 Macros Presented by Maria G. Martinez. 2 What's a macro?  Macro - set of computer instructions that you can record and associate with a shortcut key.
ME 142 Engineering Computation I Macros. Key Concepts Macro Overview Recording a Macro Running a Macro Editing a Macro Using Controls.
Introduction to VBA. This is not Introduction to Excel We’re going to assume you have a basic level of familiarity with Excel If you don’t, or you need.
11. Visual Basic Macro Recorder. Open Excel Click File -> Save As.
Week 1.  Kate Watson  Checked at least every other day. Queries and general comments welcome.
Introduction to Excel VBA University of Chicago Graduate School of Business Introduction to Computer Based Models Bus Mr. Schrage Spring 2003.
Lecture Roger Sutton CO357 Computing for Business and Accounting 13: Automation and Control (Macros and Form controls ) 1.
Spreadsheets in Finance and Forecasting Presentation 11 Visual Basic.
VBA (Visual Basic for Applications) What is Excel, just a spreadsheet? Time for Demos...
Intro to Excel CSCI130-03A Instructor: Dr. Imad Rahal LAYEROrder Application SW: Excel & Access 2 High-order P.L.: Visual Basic1 Low-order P.L.: Assembly3.
11 10/10/2005 BAE Spreadsheet Macros (Visual Basic for Applications) Slides to accompany an in-class demo of spreadsheet technique: Macro Programming.
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.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 7 BACKNEXTEND 7-1 LINKS TO OBJECTIVES Record & run a macro Record & run a macro Save as a macro-
12. Visual Basic If Statements and Do Loops. Open 12b-datastart.xlsm.
Introduction on VBA Lab 05 ins.Tahani Al_dweesh. Lab Objectives Introduction Calculation with VBA Storing and Retrieving Variables in a Worksheet Using.
European Computer Driving Licence Syllabus version 5.0 Module 4 – Spreadsheets Chapter 22 – Functions Pass ECDL5 for Office 2007 Module 4 Spreadsheets.
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
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
Class 3 Programming in Visual Basic. Class Objectives Learn about input/output Learn about strings Learn about subroutines Learn about arrays Learn about.
Question 10 What do I write?. Spreadsheet Make sure that you have got a printout of your spreadsheet - no spreadsheet, no marks!
ME 142 Engineering Computation I Macros. Key Concepts Macro Overview Recording a Macro Running a Macro Editing a Macro.
Visual Basic for Applications Macro Programming For Microsoft Office.
Intro to Excel - Session 7.31 Tutorial 7 - Session 7.3 Developing an Excel Application.
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.
# 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.
Week 4.  Recap – Ranges  For Each Loops  Ranges Referencing Range Objects  Set (keyword)
Chapter 16: Programming Structures Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Chapter 9 Macros And Visual Basic For Applications.
Chapter 16: Programming Structures Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
A spreadsheet is a programme which stores data in a grid. Many people use spread sheets as an online calculator instead of working lots of calculations.
Controls and Events. The Next Step In the first module, we discussed general problem solving In this module, we’ll apply what we learned, from specification.
Introduction to Excel VBA UNC Charlotte CPE/PDH Series December 17, 2009.
VBA Navigation, Conditionals, and Boxes. VBA Navigation.
Excel Basics. Differentiating between worksheets and spreadsheets Differentiating between workbooks and worksheets.
ME 142 Engineering Computation I Input, Output & Documentation.
Introduction to Macros in Excel Franco Musso. ActiveCell.Offset.
How to Create a form using the Program Excel By Mrs Douglas 8/1/10.
Cell Column Drawing Toolbar Formatting Toolbar Formula Bar Help Box Menu Bar Name Box Rows Standard Toolbar Title Bar Worksheet.
Chapter 15: Sub Procedures and Function Procedures Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
Groups of cells labeled with letters that go up and down (vertical)
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
VBA Programming for Excel Review Excel Objects Excel Methods Identifying Specific Cells Review Functions for Excel Custom Menus.
Excel Functions. Part 1. Introduction 2 An Excel function is a formula or a procedure that is performed in the Visual Basic environment, outside the.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
Excel Tutorial 8 Developing an Excel Application
Developing an Excel Applications
Exploring Excel Chapter 7 Automating Repetitive Tasks: Macros and
VBA (Visual Basic for Applications) What is Excel, just a spreadsheet?
Learning Excel Session 9 and 10 Dr. Chaitali Basu Mukherji.
Introducing VBA Macros
Creating Macros in Excel
Exploring Microsoft Excel
ME 142 Engineering Computation I
Lesson 1 - Automating Tasks
Experiment #2 Resistor Statistics
Microsoft Excel 2007 – Level 2
AQA specification Lesson 1: Time series and interpreting graphs
Presentation transcript:

Writing VBA Macros Record a new Macro, recording only the name, shortcut and description Stop recording Open macro for editing and enter VB code Test

Moving around the Spreadsheet To move the cursor to a particular cell (starting point)‏ Range(“A4”).select Range(“NamedCell”).select This is now the “Active Cell”

Referencing a Cell from ActiveCell ActiveCell.offset (R,C)‏ e.g. ActiveCell.offset(0,-1) refers to the cell one to the left of the ActiveCell

To place information from a VB variable into a spreadsheet Range(“D4”) = TaxRate Range(“Result”) = Sum ActiveCell = Salary * Rate ActiveCell.offset(12,0) = totalCost ActiveSheet.Cells(11,9) = Total Worksheets(“MySheet”).Cells(1,1) = title Sheet2.cells(1,3) = Title 'Refers to sheet 2 row1,column 3

To input from a spreadsheet to variable Amount = ActiveCell Amount = ActiveCell.Offset(0,-3)‏ Amount =ActiveSheet.Cells(9,1) 'current sheet Row 9, column 1

Loops Do until ActiveCell.offset(Row, 0) = “” 'put your actions here Row = Row +1 Loop

Other Features Assigning Macros to Buttons Rather than using Ctrl + Character all the time More handy to have a button Insert  Shapes Draw button Right Click on the button  Assign macro Any of the VB commands can be used InputBox ActiveCell = InputBox(“Enter you name”,”Namebox”)‏ Msgbox