Microsoft Excel Macros & Excel Solver (IENG490)

Slides:



Advertisements
Similar presentations
Introduction to Macro Introduction to Visual Basic for Application Recording a Macro Looking at the code of Recorded Macro.
Advertisements

Using VB with MS Applications R. Juhl, Delta College.
© Paradigm Publishing, Inc Excel 2013 Level 2 Unit 2Managing and Integrating Data and the Excel Environment Chapter 7Automating Repetitive Tasks.
Essence of programming  Branching  Repetitions.
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 7: Developing an Excel Application
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.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
MACROS CS1100 Computer Science and its Applications CS11001.
Microsoft Excel 2003 Illustrated Complete with Excel Programming.
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
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.
Using the Visual Basic Editor Visual Basic for Applications 1.
Macros in Excel Intro to lab 1. Macroinstructions Macro is recorded in VBA module sequence of Excel operations Macros can automate tasks in Excel Macro.
Excel Lesson 14 Creating and Using Macros Microsoft Office 2010 Advanced Cable / Morrison 1.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Macros and VBA A macro is a set of instructions that tells Excel which commands to execute.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
Microsoft Office Word 2013 Core Microsoft Office Word 2013 Core Courseware # 3250 Lesson 8: Using Productivity Tools.
Other Features Index and table of contents Macros and VBA.
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.
Customizing Microsoft Project
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.
1 CS 106 Computing Fundamentals II Chapter 17 “Introduction To VBA” Herbert G. Mayer, PSU CS status 6/30/2013 Initial content copied verbatim from CS 106.
Microsoft Excel 2007 © Wiley Publishing All Rights Reserved. The L Line The Express Line to Learning L Line.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
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-
Automating Tasks with Visual Basic. Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.
Introduction to VBA MGMI Aug What is VBA? VBA = Visual Basic for Application Excel’s powerful built-in programming language An event-driven.
Chapter 11: Introduction to the Visual Basic Environment Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
INSERT BOOK COVER 1Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Microsoft Office Excel 2010 by Robert Grauer, Keith.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
® Microsoft Office 2010 Excel Tutorial 1: Getting Started with Excel.
Chapter 12: Recording Macros Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
ME 142 Engineering Computation I Macros. Key Concepts Macro Overview Recording a Macro Running a Macro Editing a Macro.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
OCC Network Drives  H:\  P:\ 
Chapter 9 Macros And Visual Basic For Applications.
Intermacs Form Download Excel Tutorial Pivot Tables, Graphic Tools, Macros By: Devin Koehl.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft® Excel 2013.
Excel Macros 1 Macros or, How to Automate Part of Your Spreadsheet or Worksheet.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Introduction to Microsoft Excel Macros COE 201- Computer Proficiency.
Intermacs Form Download Excel Tutorial Pivot Tables, Graphic Tools, Macros By: Devin Koehl.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft® Excel 2013.
MICROSOFT WORD PRESENTATION. Word Processing  Software that is designed for the entry, editing, and printing of documents.  Windows Version = Microsoft.
1 CA202 Spreadsheet Application Automating Repetitive Tasks with Macros Lecture # 12 Dammam Community College.
Macros in Excel Using VBA Time Required – 5 hours.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Microsoft Excel Consolidation. Contents Introduction to Multiple Workbook Applications Working with Multiple Workbook Applications using normal keyboard.
Excel Tutorial 8 Developing an Excel Application
June 17, 2009 Office 2007 Tips & Tricks.
1. Introduction to Visual Basic
Microsoft Excel 2003 Illustrated Complete
Introducing VBA Macros
Exploring Microsoft® Excel® 2016 Series Editor Mary Anne Poatsy
Exploring Microsoft Excel
ME 142 Engineering Computation I
Macro.
Lesson 1 - Automating Tasks
Objectives At the end of this session, students will be able to:
Microsoft Excel 2007 – Level 2
Visual Basic for Applications: Introduction
Presentation transcript:

Microsoft Excel Macros & Excel Solver (IENG490) Spring:(2013-2014) Research Assistants: Arman Nedjati & Mahmoud Golabi

Excel Solver

Example1

Example2

Example2

Contents of Macros Introduction to Macro Introduction to Visual Basic for Application Recording a Macro Looking at the code of Recorded Macro

Introduction to Visual Basic for Application Microsoft Excel in itself a tool which helps users to work with worksheets & workbooks with ease. This tool is one of the ultimate timesaver, but there are numerous events when you have to do repetitive tasks which are of a very little value but consume your precious time; yet engage you in a less productive activity, which Excel may do automatically. Microsoft Excel macro is the feature which eliminates or at-least minimize these events which take your precious time in repetitive tasks, and you will be able to capitalize this time in more productive & strategic activities.

Introduction to Visual Basic for Application - cont… Apart from automating repetitive tasks Microsoft Excel Macros may also be used to create user interfaces User interfaces are screens where user can give inputs with ease also it enables input validations

Introduction to Visual Basic for Application - cont… What is Visual Basic? Visual Basic is a language which is inherited from a very popular language BASIC. BASIC stands for Beginners All-purpose Symbolic Instruction Code. Visual Basic is called visual as you can do most of the program by click and go i.e. visually. It’s an event driven & object based language. What is Event Driven Language? When we say event driven it means that you can write triggers which will initiate on specific events for example when user opens any document or saves any document What is Object Based Language? Object based language is language in which we can use objects & their properties i.e. we can use the Worksheet object and its property SheetName when some one clicks on a button

Introduction to Visual Basic for Application - cont… Visual Basic for Application Visual Basic for Application is called VBA as it uses Visual Basic language and is capable of using application specific objects i.e. if we talk about VBA for Excel it can use Cell Object, Range Object, Worksheet Object, Workbook Object etc.

Recording your first Macro Microsoft Excel provides you a very helpful option which enables you to record a macro and also modify and run afterwards Microsoft Excel don’t provide you the macro recording option by default for enabling macro recording at first you need to enable the Developer Tab, next slide defines step by step procedure to enable Developer Tab

Enabling the Developer Tab Click on File Click on Excel Options On Customize Ribbon check Developer tab 2 3 1

Enabling the Developer Tab

Recording your first Macro When you record macro Microsoft Excel provides you with 2 options either you can record a macro using Absolute References or Relative References If you go for Absolute References Excel’s behavior will be: You record a macro in Cell A1 type “Excel is Great” format Bold Cell B1 Whenever you play / run this macro Excel will always type “Excel is Great” in Cell A1 and format Bold Cell B1 no matter wherever your cursor is

Recording your first Macro You can refer to following tab that you can click on Use Relative References which will enable you to record a macro in relative cells, as discussed whenever a relative reference macro is executed it will run in-place

Recording your first Macro Click Developer Tab Click on Use Relative Reference Click on Record Macro 1 3 2

Recording your first Macro As soon as you press record macro button the following screen will appear In the Macro name box you have to type the name of macro In Shortcut key you can type short cut key which invoke the Macro Store macro (will discussed later) You can also provide description of the macro

Recording your first Macro As soon as you press OK in the previous dialog box two things happens first record macro button changes to Stop Recording Secondly Excel starts looking for your action and will record the same Please follow steps on the following slide to complete recording

Recording your first Macro Click on Cell A1 type “Excel is Great” Select cells from A1:C1 click on Home Tab and click on Merge & Center Press Bold & Italics Now click on Developer Tab and click on Stop recording

Playing your Macro You can execute the macro you just recorded by either clicking on the Macro button on the Developer Tab or by pressing Alt F8 , you can see the list of Recorded macros in the dialog box you can press Run button to execute the macro as soon as you press run you can see that your recorded macro will execute

Behind the scenes To see what Excel did behind the scenes you can either click on Macros button on Developer Tab and select Edit or you can press Alt F11

What it looks like This is what Excel did behind the scenes, it written the code for you. You can change the code if you want. You can either close the window or press Alt F11 again to go back to your Excel normal screen.

Example1

Example1

Example1 Working with Excel while recording the macro

Example1

Example1

Example1

Looking inside the VB code of our Macro

Using Form Controls

Using Form Controls Using the Form Controls select a GUI element and by mouse-click place it on the frame

Using Form Controls

The Cell and click on button Using Form Controls Select The Cell and click on button

Example2: Develop a macro to calculate the average of five cells to the left of a selected cell. Initialize a spreadsheet and fill five vertical cells with numbers. Select the cell to the right

Example2 Start macro-recording and modify macro properties

Example2 Input formula in cell C2 and then stop macro-recording.

Example2 Test the macro by filling other five cells with numbers, then select the cell to the right and then click shortcut-key. (we had chosen [Ctrl-a] )

Example2 Click [Alt-F11] to access VBA module

Example3 Step 1. Click [Alt-F11] to open the Visual Basic Editor. Writing a subroutine to solve a set of linear equations while allowing the user to input cell-range. Step 1. Click [Alt-F11] to open the Visual Basic Editor. Step 2. Select [Insert][Module].

Example3 Step 3. Type in the following code:

Example3 Step 4. Go back to the Excel workbook by clicking [Alt-F11] once more. Then click [Alt-F8] to change the macro options and select shortcut key (plus add description if desired).

Example3 Step 5. Test the macro. First prepare the spreadsheet with a matrix which will be treated as matrix A and column of cells to be treated as vector b. Then run the macro.

Conclusion Macros are used to automate tasks or you can use macros to develop user interfaces Excel Macro use a language called VBA (Visual Basic for Applications), which is both Event Driven and Object Based The easiest way to look at macro is by using the Excel’s record Macro Feature You can even edit Excel’s recorded macro by yourself Soon we will publish a presentation which will guide you on how to write your own macro

FINISH