Macros: Programming Excel/VBA Part II (A.Fring)

Similar documents
MS WORD 2007 (PC) Macros and Track Changes Please note the latest Macintosh version of MS Word does not have Macros.

Macros in Word & Excel

Migrating to Excel 2010 from Excel Excel - Microsoft Office 1 of 1

Using Excel for Business Analysis: A Guide to Financial Modelling Fundamentals

ECDL. European Computer Driving Licence. Spreadsheet Software BCS ITQ Level 2. Syllabus Version 5.0

SOAL-SOAL MICROSOFT EXCEL 1. The box on the chart that contains the name of each individual record is called the. A. cell B. title C. axis D.

Excel 2003 A Beginners Guide

Word 2010: Mail Merge to with Attachments

Excel 2007 A Beginners Guide

Microsoft Migrating to Word 2010 from Word 2003

1. a procedure that you perform frequently. 2. Create a command. 3. Create a new. 4. Create custom for Excel.

Computer Training Centre University College Cork. Excel 2013 Level 1

Excel Pivot Tables. Blue Pecan Computer Training Ltd - Onsite Training Provider :: :: info@bluepecan.co.

Introduction To Microsoft Office Excel Bob Booth July 2008 AP-Excel8

Move between open workbooks. Display the print menu. Select whole spreadsheet. Microsoft Excel Keyboard Keys. General

Microsoft Excel 2013: Macro to apply Custom Margins, Titles, Gridlines, Autofit Width & Add Macro to Quick Access Toolbar & How to Delete a Macro.

To create a histogram, you must organize the data in two columns on the worksheet. These columns must contain the following data:

Excel & Visual Basic for Applications (VBA)

Working with Macros and VBA in Excel 2007

Pivot Tables & Pivot Charts

Fractions to decimals

Excel macros made easy

Microsoft Excel Introduction to Microsoft Excel 2007

To export data formatted for Avery labels -

Writing Macros in Microsoft Excel 2003

Microsoft Excel 2010 Tutorial

Microsoft Excel 2013: Headers and Footers

Basic Microsoft Excel 2007

Formulas & Functions in Microsoft Excel

Introduction to Microsoft Excel 2010

Search help. More on Office.com: images templates. Here are some basic tasks that you can do in Microsoft Excel 2010.

What is Microsoft Excel?

Excel basics. Before you begin. What you'll learn. Requirements. Estimated time to complete:

Microsoft Excel 2013 Tutorial

Using Microsoft Project 2000

Excel 2010 Sorting and Filtering

Microsoft Word 2010 Basics

Advanced Presentation Features and Animation

Excel 2007 Introduction to Macros

Excel 2007 Basic knowledge

Task Force on Technology / EXCEL

Q&As: Microsoft Excel 2013: Chapter 2

Adding Comments in Microsoft Excel 2003

Automate tasks with Visual Basic macros

Formulas & Functions in Microsoft Excel

EXCEL Using Excel for Data Query & Management. Information Technology. MS Office Excel 2007 Users Guide. IT Training & Development

To reuse a template that you ve recently used, click Recent Templates, click the template that you want, and then click Create.

warpct.com Working with MS Excel 2003 Workbook courseware by WARP! Computer Training

Computer Skills Microsoft Excel Creating Pie & Column Charts

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

Microsoft PowerPoint Tutorial

The Basics of Microsoft Excel

Draw pie charts in Excel

Basic Excel Handbook

Formatting Formatting Tables

Excel 2003 Tutorial I

Microsoft Publisher 2010 What s New!

Microsoft Migrating to PowerPoint 2010 from PowerPoint 2003

How to Use Excel 2007

Microsoft Word 2010 Prepared by Computing Services at the Eastman School of Music July 2010

Microsoft Word 2010 Tutorial

Microsoft Excel Training - Course Topic Selections

VBA PROGRAMMING FOR EXCEL FREDRIC B. GLUCK

Excel -- Creating Charts

Excel Spreadsheets: Getting Started

Tommy B. Harrington 104 Azalea Drive Greenville, NC

Intermediate. Microsoft Excel Tables and Printing

MS Word 2007 practical notes

Microsoft Word 2013 Tutorial

Introduction to Microsoft Excel 1 Part I

Microsoft Word Quick Reference Guide. Union Institute & University

Microsoft Excel 2010 Part 3: Advanced Excel

Working with sections in Word

MS Excel. Handout: Level 2. elearning Department. Copyright 2016 CMS e-learning Department. All Rights Reserved. Page 1 of 11

EXCEL PIVOT TABLE David Geffen School of Medicine, UCLA Dean s Office Oct 2002

To launch the Microsoft Excel program, locate the Microsoft Excel icon, and double click.

Create Charts in Excel

Excel 2007: Basics Learning Guide

Microsoft Excel 2007 and Tools for Statistical Analysis David R. Anderson, Dennis J. Sweeney, and Thomas A. Williams

GOOGLE DOCS APPLICATION WORK WITH GOOGLE DOCUMENTS

The Center for Teaching, Learning, & Technology

Excel. Microsoft Office s spreadsheet application can be used to track. and analyze numerical data for display on screen or in printed

Handout: Word 2010 Tips and Shortcuts

Create a Poster Using Publisher

Microsoft Excel 2013 Step-by-Step Exercises: PivotTables and PivotCharts: Exercise 1

Explore commands on the ribbon Each ribbon tab has groups, and each group has a set of related commands.

Introduction To Microsoft Office PowerPoint Bob Booth July 2008 AP-PPT5

Excel 2010: Create your first spreadsheet

Microsoft Word 2013 Basics

Excel 2003 PivotTables Summarizing, Analyzing, and Presenting Your Data

Business Objects Version 5 : Introduction

Scientific Graphing in Excel 2010

EXCEL SOLVER TUTORIAL

Word basics. Before you begin. What you'll learn. Requirements. Estimated time to complete:

Keyboard shortcuts in Excel Keyboard access to the ribbon. In this article WILL MY OLD SHORTCUTS STILL WORK? Hide All

Microsoft Excel Understanding the Basics

BIGPOND ONLINE STORAGE USER GUIDE Issue August 2005

CREATING FORMAL REPORT. using MICROSOFT WORD. and EXCEL

Years after US Student to Teacher Ratio

Using PowerPoint Short Course

Transcription:

Macros: In Labsession 11 you have already seen how to write a subroutine (Macro) using the VBA editor. (not UDF) Alternatively you can also create them with the Macro recorder. In this way you do not need to know any VBA commands. 1) Recording a Macro: i) open a worksheet ii) select Tools Macro Record New Macro the record Macro dialog box opens up 11 iii) enter Macro Name, e.g. SumA1toA30 - not all names are allowed, such as function names, special signs in the name as!,?, blank,... are also not possible iv) enter a letter for the shortcut key, e.g. s v) store the macro somewhere, e.g. This workbook vi) fill in the decription box, e.g. sum up the cells A1:A30 vii) Ok, the recording is on. Now all actions you carry out on the worksheet will be recorded and its code will be produced. 12

viii) For example: Carry out an action which sums up the cells A1:A30 - select a cell in your worksheet different from column A - write: The sum of the cells A1:A30 is: - select the adjacent cell and write: =Sum(A1:A30) - the effect of this is that in the cell in which you wrote =Sum(A1:A30) this sum will be displayed if a cell is empty its value contributes zero to the sum you can now change the content of A1:A30 and the sum will be updated automatically ix) - select Tools Macro Stop Recording - alternatively in the window on the worksheet select Stop Recording - if that window is now visible, you can make it appear by selecting Edit Toolbars Stop Recording 13 2) Viewing the code: - The recording has produced a VBA code, which alternatively we could have programmed by hand: - Let s see what we have just produced: - Select Tools Macro Macros a window called Macros opens up - the window Macro name shows the name of the Macro - in case you have many Macros: select Options to see the details of it (in case you do not remember) - Select Edit the code we have just produced will show up 14

Sub SumA1toA30() ' ' SumA1toA30 Macro ' sum up the cells A1:A30 ' ' Keyboard Shortcut: Ctrl+s ' Range("F12").Select ActiveCell.FormulaR1C1 = "The sum of the cells A1:A30 is:" Range("I12").Select ActiveCell.FormulaR1C1 = "=SUM(R[-11]C[-8]:R[18]C[-8])" End Sub 15 3) Activating the Macro: i) Select Tools Macro Macros a window called Macros opens up the macro s name appears in the window Macro name: in case you have more than one, select the one you want Select Run what you have recorded before will be executed now ii) Use the shortcut: - our example just: Ctl + s iii) If you were editing the code: Select a window called Macros opens up i) iv) Using customized buttons or other objects: - we have to see first how to create those (see point 4): 15

Example: We calculate once more - first you have to fill in: 1 A1, 2 A2, 3 A3... 30 A30 - you can do this by hand, but the faster way is to use Series : - put 1 into cell A1: - select Edit Fill Series a window called Series opens up - Fill in: Series: Column Type: Linear Step value: 1 Stop value: 30 -Ok - activate the Macro The sum of the cells A1:A30 is 465 17 4) Customized buttons (and other objects): i) Make the Forms toolbar visible: Select Tools Customize Toolbars Forms Close a new toolbar with possible form commands open up 18

ii) Assign a Macro to a button: - Select Button (a grey box) select a cell in your worksheet the Assign Macro window opens up select the Macro which you want to attach to this button, e.g. SumA1toA30 Ok it says now Button # on your button 19 iii) Activating the Macro: - Selecting now this button will activate the Macro you have attached to it, e.g. SumA1toA30 iv) Changing the button design: attach a better text to the button: - select the right mouse button (moving first over the button) a variety of commands opens up: select Edit text type a meaningful text onto the button, e.g. Sum A1 to A30 change the size of the button: - select the right mouse button (moving first over the button) select Format Control 20

change the size of the button: - select the right mouse button (moving first over the button) select Format Control Alignment Automatic size Ok 21 similarly you can change the writing direction, the text fonts, the text and button size, the margins of the button, the colour, the status of the protection, etc. You can also assign Macros to other objects: the symbol from the forms toolbar a text label Aa on the forms toolbar other symbols from the forms toolbar a picture you have imported before such as 22 (Select Insert Picture From File or Clip Art choose a picture)