How to Create a For Next Loop in Excel VBA!

Size: px
Start display at page:

Download "How to Create a For Next Loop in Excel VBA!"

Transcription

1 Often when writing VBA code, one may need to repeat the same action or series of actions more than a couple of times. One could, in this case, write each action over and over in one s code or alternatively one could use a better option and that is using loops. Looping is a key structural element of most programming languages. So, it s a good idea to familiarize oneself with looping in order to not only write more efficient code but also to understand code others have written. Looping allows one to handle repetitive tasks in one s code using a loop structure. The simplest type of loop structure is the For Next Loop structure. This structure handles cases where one has to repeat a certain action, or set of statements for a finite number of times specified. So let s look at a few simple examples of how to use the For Next Loop Structure. Table of Contents 1 Introduction 2 Using the For Next Loop 3 Using the Step Keyword with the For Next Loop 3.1 Using a Positive Step Value 3.2 Using a Negative Step Value 4 Download Working File 5 Conclusion 6 Review Section: Test your Understanding 7 Useful Links Introduction We have a blank workbook and we want to give the cells A1: A20, a light blue fill using VBA first with a manual repetitive approach and then with a For Next Loop. Our source workbook is shown below. All rights reserved to ExcelDemy.com. 1

2 1) The first thing we are going to do is repeat the action required, a number of times, for each cell in the range, using VBA, in other words, we are not going to use the For Next Loop structure at first. Since we want to see how to complete the task using a repetitive block of code only. 2) So, go to Developer>Controls>Insert and under the ActiveX Controls section, choose Command Button. All rights reserved to ExcelDemy.com. 2

3 3) Draw a command button on the worksheet. All rights reserved to ExcelDemy.com. 3

4 4) Using the Properties Window, name the Command button, cmdwithoutloop and the caption to Fill without using a loop. All rights reserved to ExcelDemy.com. 4

5 All rights reserved to ExcelDemy.com. 5

6 5) Right-click the button and select View Code. All rights reserved to ExcelDemy.com. 6

7 6) Enter the following code for the button click event, in order to fill the cells in range A1: A20 with a light blue fill, using a repetitive coding block. Private Sub cmdwithoutloop_click() Cells(1, A ).Interior.Color = RGB(156, 207, 212) Cells(2, A ).Interior.Color = RGB(156, 207, 212) Cells(3, A ).Interior.Color = RGB(156, 207, 212) Cells(4, A ).Interior.Color = RGB(156, 207, 212) All rights reserved to ExcelDemy.com. 7

8 Cells(5, A ).Interior.Color = RGB(156, 207, 212) Cells(6, A ).Interior.Color = RGB(156, 207, 212) Cells(7, A ).Interior.Color = RGB(156, 207, 212) Cells(8, A ).Interior.Color = RGB(156, 207, 212) Cells(9, A ).Interior.Color = RGB(156, 207, 212) Cells(10, A ).Interior.Color = RGB(156, 207, 212) Cells(11, A ).Interior.Color = RGB(156, 207, 212) Cells(12, A ).Interior.Color = RGB(156, 207, 212) Cells(13, A ).Interior.Color = RGB(156, 207, 212) Cells(14, A ).Interior.Color = RGB(156, 207, 212) Cells(15, A ).Interior.Color = RGB(156, 207, 212) Cells(16, A ).Interior.Color = RGB(156, 207, 212) Cells(17, A ).Interior.Color = RGB(156, 207, 212) Cells(18, A ).Interior.Color = RGB(156, 207, 212) Cells(19, A ).Interior.Color = RGB(156, 207, 212) Cells(20, A ).Interior.Color = RGB(156, 207, 212) End Sub 7) Return to the worksheet and making sure Design Mode is not activated, click on the button and the cells specified in the code will now be filled with a light blue colour as shown below. All rights reserved to ExcelDemy.com. 8

9 Now nothing stops one from using these kinds of repetitive programming blocks, however accomplishing the task this way can be time-consuming and laborious. Let s say one had to fill 1000 cells with the blue fill (A1: A1000), to manually specify each cell in the code would be impractical. The general rule of thumb is that if one needs to type more than three lines of the same repetitive code, then one should rather look at accomplishing the task using a loop. However, it is not mandatory and when first starting out, one may prefer to use repetitive coding blocks, but as one s VBA reaches more advanced levels, looping becomes a All rights reserved to ExcelDemy.com. 9

10 necessity. Using the For Next Loop The For Next Loop is very simple to use and understand. In order to use the For Next Loop, one must know the number of iterations required. Also, the start value and ending value must be specified. In our designated example, given above, we need to repeat the code 20 times in order to fill the cells A1: A20 with the light blue fill. We are starting at cell A1 and ending at cell A20. The basic structure of the For Next Loop is the following: Declare the type of counting variable. This variable is used to count the number of times the action needs to be repeated, it, therefore, is most often of integer type. Dim variable as Integer Open the loop structure and state the starting and ending values of the counting variable. For variable = 1 to the number of finite times, the action needs to be repeated Enter the command/action/statement that needs to be repeated. Using the Next keyword and the variable, loop to the next iteration. Next variable So, let s see how to do this using our example. 1) First, things first, select the range A1: A20 and go to Home>Font>Fill>No Fill in order to restore the cells back to their original condition. All rights reserved to ExcelDemy.com. 10

11 2) Then create another button, by going to Developer>Controls>Insert and under the ActiveX Controls section, choose Command Button and draw another button on the worksheet. All rights reserved to ExcelDemy.com. 11

12 3) Using the Properties Window, name the Command button, cmdusingloop and the caption to Fill using a For Next loop. All rights reserved to ExcelDemy.com. 12

13 4) Right-click the button and select View Code. 5) Enter the following code for the button click event in order to fill the cells in range A1: A20 with a light blue fill, using a For Next Loop structure. Private Sub cmdusingloop_click() Dim varcounter As Integer All rights reserved to ExcelDemy.com. 13

14 For varcounter = 1 To 20 Cells(varcounter, A ).Interior.Color = RGB(156, 207, 212) Next varcounter End Sub 6) Return back to the worksheet and make sure Design Mode is not activated click on the second button. All rights reserved to ExcelDemy.com. 14

15 7) The cells A1: A20 are now filled with the light blue fill. In our code, we have first set a variable called varcounter of integer type. This is the variable that is going to keep track of the number of iterations, we will specify using the loop. We then open the For Next Loop structure using the For keyword and our counting variable. We also designate the starting value for our variable and where we want it to end, in this case, our starting value is 1 and our ending value is 20. For our required action, instead of writing out each row individually as we did before in the repetitive coding block, All rights reserved to ExcelDemy.com. 15

16 we simply use the variable instead. We then use the Next keyword in order to iterate or repeat the action, according to the number of times specified. We can see that using the For Next loop structure considerably lessened the code needed, which is one distinct advantage of using loops. Our code also looks neater and is easier to understand. Also if let s say we had to fill the cells A1: A1000 with the light blue fill, instead of manually specifying the cells to be filled as we did when we were using the repetitive coding block, we could just adjust the code and in the For line set the end value to 1000 instead of 20. When the button is clicked, the cells from A1: A1000 would now be filled. This would save a considerable amount of typing and effort. The adjusted code for the Loop is shown below, in the case of A1000 being the last cell needing to be filled with the light blue fill. Private Sub cmdusingloop_click() Dim varcounter As Integer For varcounter = 1 To 1000 Cells(varcounter, A ).Interior.Color = RGB(156, 207, 212) Next varcounter End Sub Using the Step Keyword with the For Next Loop The Step keyword is an optional keyword that can be used in conjunction with the For Next Loop Structure. By default without it, the For Next Loop size is 1. When the Step value is specified, the counting variable increments by the specific step size set. The Step value can be either a positive or a negative integer. By specifying the Step value, one directly increments the counter as the loop proceeds. This concept is best demonstrated with an example. Using a Positive Step Value We now would like to fill every second cell in the range A1: A20, starting on cell A1, and then moving to A3 and so on, with a light green fill, using the For Next Loop structure with the Step keyword, and a positive step value. In this case, our step value would be positive 2, since we are incrementing using a value of 2. 1) On the worksheet called Step, go to Developer>Controls>Insert and under the ActiveX Controls section, choose Command Button and draw a button on the worksheet. 2) Using the Properties Window, name the Command button, cmdusingloopwithstep and the caption to Fill using a For Next loop With a Positive Step Value. All rights reserved to ExcelDemy.com. 16

17 3) Right-click the button and select View Code. 4) Enter the following code for the button click event in order to fill every second cell in range A1:A20 with a light green fill (we will start on cell A1 and fill this cell with the light green fill and then every second cell from there onwards will also receive the light green fill), using a For Next Loop structure with the Step keyword. Private Sub cmdusingloopwithstep_click() Dim icounter As Integer For icounter = 1 To 20 Step 2 Cells(icounter, A ).Interior.Color = RGB(171, 248, 128) All rights reserved to ExcelDemy.com. 17

18 Next icounter End Sub 5) Return back to the worksheet and make sure Design Mode is not activated click on the button. 6) Every second cell in the range is now filled with the light green fill, starting with cell A1 and then moving by an increment of 2, due to us specifying using the Step keyword. All rights reserved to ExcelDemy.com. 18

19 Using a Negative Step Value We now would like to fill cells A2, A4, A6, A8, A10, A12, A14, A16, A18 and A20 with a grey fill, using the For Next Loop structure with the Step keyword, using a negative step value. In this case, our step value is negative 2 since we are starting at cell A20 and then counting down technically due to the negative 2 value. 1) On the worksheet called Step, go to Developer>Controls>Insert and under the ActiveX Controls section, choose Command Button and draw the second button on the worksheet. 2) Using the Properties Window, name the Command button, cmd using loop with negative Step and the caption to Fill using a For Next loop With a Negative Step Value. 3) Right-click the button and select View Code. 4) Enter the following code for the button click event in order to fill the cells A2, A4, A6, A8, A10, A12, A14, A16, A18 and A20 with a grey fill, using a For Next Loop structure with the Step keyword and a negative value. Private Sub cmdusingloopwithnegativestep_click() Dim icountertwo As Integer For icountertwo = 20 To 1 Step -2 Cells(icountertwo, A ).Interior.Color = RGB(173, 173, 173) Next icountertwo End Sub 5) Return back to the worksheet and make sure Design Mode is not activated click on the button. 6) Every second cell in the range is now filled, starting with cell A20 and then moving 2 up, with the grey fill, due to us specifying using the Step keyword. All rights reserved to ExcelDemy.com. 19

20 7) Remember to save your workbook as a macro-enabled workbook if you haven t done so already. We can see when using the For Next Loop structure with a negative Step value, the sequence is slightly different and we start counting from the highest value downwards. Download Working File LoopsForNext Conclusion Looping allows one to handle repetitive actions, in an efficient manner. VBA provides different types of Loops and the simplest one is the For Next Loop, and this is used when one has a finite number of actions/iterations needing to be completed. This loop structure can also be used in conjunction with a step value which can be either positive or negative, All rights reserved to ExcelDemy.com. 20

21 which allows slightly more flexibility and functionality with respect to incrementing. Please feel free to tell us if you use the For Next Loop structure in your VBA code. Review Section: Test your Understanding 1) What is a loop? 2) When does one use a looping structure and what are the key advantages of using loops in one s VBA code? 3) What is the general syntax of the For Next Loop? 4) What is the difference between using a positive Step Value versus a negative Step Value in a For Next Loop. 5) Using a For Next Loop structure, create a macro that fills the columns A: J with a light grey fill. 6) Using a For Next Loop structure, create a macro that fills every second column from Column A (starting at Column A) to Column J with a light blue fill. Useful Links Looping in Excel Using the For Next Loop in Excel A complete introduction to VBA Loops 3 SHARES FacebookTwitter Taryn N Taryn is a Microsoft Certified Professional, who has used Office Applications such as Excel and Access extensively, in her interdisciplinary academic career and work experience. She has a background in biochemistry, Geographical Information Systems (GIS) and biofuels. She enjoys showcasing the functionality of Excel in various disciplines. In her spare time when she s not exploring Excel or Access, she is into graphic design, amateur photography and caring for her two pets, Pretzel and Snoopy. All rights reserved to ExcelDemy.com. 21

How to Use Do While Loop in Excel VBA

How to Use Do While Loop in Excel VBA We have already covered an introduction to looping and the simplest type of loops, namely the For Next Loop and the For Each Next Loop, in previous tutorials. We discovered that the For Next Loop and the

More information

Read More: Index Function Excel [Examples, Make Dynamic Range, INDEX MATCH]

Read More: Index Function Excel [Examples, Make Dynamic Range, INDEX MATCH] You can utilize the built-in Excel Worksheet functions such as the VLOOKUP Function, the CHOOSE Function and the PMT Function in your VBA code and applications as well. In fact, most of the Excel worksheet

More information

Changing Case using Worksheet Functions and Excel VBA

Changing Case using Worksheet Functions and Excel VBA Excel provides the text worksheet functions, namely the Upper Function, the Lower Function and the Proper Function, which can change the case of a specified input text string. This text string could be

More information

Do Until Loop in Excel VBA with Examples

Do Until Loop in Excel VBA with Examples The Do Until Loop Structure is utilized, when one has a set of statements or actions to be repeated and repetition occurs until the condition evaluates to true, in other words, while the condition is false

More information

How to Use the Select Case Structure in Excel VBA

How to Use the Select Case Structure in Excel VBA One can implement conditional logic in VBA using an IF statement, multiple IF-Elseif statements or one can use the Select Case statement in order to implement conditional logic. In the case where one has

More information

MAX vs MAXA vs LARGE and MIN vs MINA vs SMALL Functions in Excel

MAX vs MAXA vs LARGE and MIN vs MINA vs SMALL Functions in Excel provides functions to calculate the largest or maximum value in a range and also functions to calculate the smallest or minimum value in a range. The first function we are going to look at is the MAX Function.

More information

Read More: How to Make Excel Graphs Look Professional & Cool [10 Awesome Tips]!

Read More: How to Make Excel Graphs Look Professional & Cool [10 Awesome Tips]! How to Modify Color, Font, & Effects & Create Custom Excel Excel has themes, which have different default colors, auto shape effects, SmartArt effects, and fonts. When utilizing themes one can quickly

More information

So let s get started with a simple example to illustrate the difference between the worksheet level protection and workbook level protection.

So let s get started with a simple example to illustrate the difference between the worksheet level protection and workbook level protection. It is often necessary to protect either the sensitive information in one s actual worksheet or the workbook structure, from being edited. Excel provides different options for protecting and securing one

More information

Exchange (Copy, Import, Export) Data Between Excel and Access

Exchange (Copy, Import, Export) Data Between Excel and Access Excel usage is widespread and Excel is often the go-to Office application for data entry, analysis, and manipulation. Microsoft Access provides relational database capability in a compact desktop environment.

More information

Read More: How to Make a Pie Chart in Excel [Video Tutorial]

Read More: How to Make a Pie Chart in Excel [Video Tutorial] Most of us are familiar with standard Excel chart types such as a pie chart, a column chart, and a line chart, as well as the types of data they are used to showcase visually. Excel, however, offers a

More information

Read More: How to Create Combination Charts with a Secondary Axis in Excel

Read More: How to Create Combination Charts with a Secondary Axis in Excel A pie chart is used to showcase parts of a whole or proportions of a whole. Charts are visual representations of data that can summarize large data sets and are useful for engaging one s audience. As always,

More information

Introduction to VBA for Excel-Tutorial 7. The syntax to declare an array starts by using the Dim statement, such that:

Introduction to VBA for Excel-Tutorial 7. The syntax to declare an array starts by using the Dim statement, such that: Introduction to VBA for Excel-Tutorial 7 In this tutorial, you will learn deal with arrays. We will first review how to declare the arrays, then how to pass data in and how to output arrays to Excel environment.

More information

The For Next and For Each Loops Explained for VBA & Excel

The For Next and For Each Loops Explained for VBA & Excel The For Next and For Each Loops Explained for VBA & Excel excelcampus.com /vba/for-each-next-loop/ 16 Bottom line: The For Next Loops are some of the most powerful VBA macro coding techniques for automating

More information

Download the files from you will use these files to finish the following exercises.

Download the files from  you will use these files to finish the following exercises. Exercise 6 Download the files from http://www.peter-lo.com/teaching/x4-xt-cdp-0071-a/source6.zip, you will use these files to finish the following exercises. 1. This exercise will guide you how to create

More information

LmÉPï C Á npï À ƵÀ ïì itech Analytic Solutions

LmÉPï C Á npï À ƵÀ ïì itech Analytic Solutions LmÉPï C Á npï À ƵÀ ïì itech Analytic Solutions No. 9, 1st Floor, 8th Main, 9th Cross, SBM Colony, Brindavan Nagar, Mathikere, Bangalore 560 054 Email: itechanalytcisolutions@gmail.com Website: www.itechanalytcisolutions.com

More information

DATA 301 Introduction to Data Analytics Microsoft Excel VBA. Dr. Ramon Lawrence University of British Columbia Okanagan

DATA 301 Introduction to Data Analytics Microsoft Excel VBA. Dr. Ramon Lawrence University of British Columbia Okanagan DATA 301 Introduction to Data Analytics Microsoft Excel VBA Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca DATA 301: Data Analytics (2) Why Microsoft Excel Visual Basic

More information

How to Generate Random Numbers in Excel (Ultimate Guide)

How to Generate Random Numbers in Excel (Ultimate Guide) Random numbers are those numbers which are generated by a process in which the outcome is not predictable and in a defined interval/set, the values are uniformly distributed. Random numbers are used in

More information

How to Reduce Large Excel File Size (Ultimate Guide)

How to Reduce Large Excel File Size (Ultimate Guide) Handling a large file is important as it takes a huge amount of time to transfer. A large file takes too much time to open. Any kind of change in a large file takes a long time to update. So, reducing

More information

Read More: Keyboard Shortcuts for Moving around Excel Spreadsheets

Read More: Keyboard Shortcuts for Moving around Excel Spreadsheets You will do all your works in a workbook file. You can add as many worksheets as you need in a workbook file. Each worksheet appears in its own window. By default, Excel workbooks use a.xlsx file extension.

More information

Assessed Exercise 1 Working with ranges

Assessed Exercise 1 Working with ranges Week 3 Assessed Exercise 1 Working with ranges Multiple representations Different thing in different cases Single cell Collection of cells The handle to the thing you want to work with Many operations

More information

This chapter is intended to take you through the basic steps of using the Visual Basic

This chapter is intended to take you through the basic steps of using the Visual Basic CHAPTER 1 The Basics This chapter is intended to take you through the basic steps of using the Visual Basic Editor window and writing a simple piece of VBA code. It will show you how to use the Visual

More information

Computer Science Lab Exercise 1

Computer Science Lab Exercise 1 1 of 10 Computer Science 127 - Lab Exercise 1 Introduction to Excel User-Defined Functions (pdf) During this lab you will experiment with creating Excel user-defined functions (UDFs). Background We use

More information

You can record macros to automate tedious

You can record macros to automate tedious Introduction to Macros You can record macros to automate tedious and repetitive tasks in Excel without writing programming code directly. Macros are efficiency tools that enable you to perform repetitive

More information

Sébastien Mathier wwwexcel-pratiquecom/en While : Loops make it possible to repeat instructions a number of times, which can save a lot of time The following code puts sequential numbers into each of the

More information

Excel has a powerful automation feature that lets you automate processes that you need to do repeatedly.

Excel has a powerful automation feature that lets you automate processes that you need to do repeatedly. Professor Shoemaker There are times in Excel when you have a process that requires several or many steps and that you need to do repeatedly. Excel has a powerful automation feature that lets you automate

More information

Getting started 7. Writing macros 23

Getting started 7. Writing macros 23 Contents 1 2 3 Getting started 7 Introducing Excel VBA 8 Recording a macro 10 Viewing macro code 12 Testing a macro 14 Editing macro code 15 Referencing relatives 16 Saving macros 18 Trusting macros 20

More information

HOW TO ACE THE 21 MOST COMMON QUESTIONS IN VBA 1

HOW TO ACE THE 21 MOST COMMON QUESTIONS IN VBA 1 TABLE OF CONTENTS Introduction Where does Debug.Print write to? How to open a closed Workbook How to find the last row How to use VLookup How to return a value from a function How to add a formula to a

More information

MS Excel VBA Class Goals

MS Excel VBA Class Goals MS Excel VBA 2013 Class Overview: Microsoft excel VBA training course is for those responsible for very large and variable amounts of data, or teams, who want to learn how to program features and functions

More information

<excelunusual.com> Easy Zoom -Chart axis Scaling Using VBA - by George Lungu. <www.excelunusual.com> 1. Introduction: Chart naming: by George Lungu

<excelunusual.com> Easy Zoom -Chart axis Scaling Using VBA - by George Lungu. <www.excelunusual.com> 1. Introduction: Chart naming: by George Lungu Easy Zoom -Chart axis Scaling Using VBA - by George Lungu Introduction: - In certain models we need to be able to change the scale of the chart axes function of the result of a simulation - An Excel chart

More information

Supporting the CDISC Validation Life-Cycle with Microsoft Excel VBA

Supporting the CDISC Validation Life-Cycle with Microsoft Excel VBA PharmaSUG 2017 - Paper AD23 Supporting the CDISC Validation Life-Cycle with Microsoft Excel VBA ABSTRACT Eric Crockett, Chiltern International Clinical research is increasingly based on standardized Clinical

More information

Lab 7 Macros, Modules, Data Access Pages and Internet Summary Macros: How to Create and Run Modules vs. Macros 1. Jumping to Internet

Lab 7 Macros, Modules, Data Access Pages and Internet Summary Macros: How to Create and Run Modules vs. Macros 1. Jumping to Internet Lab 7 Macros, Modules, Data Access Pages and Internet Summary Macros: How to Create and Run Modules vs. Macros 1. Jumping to Internet 1. Macros 1.1 What is a macro? A macro is a set of one or more actions

More information

CHAPTER 1 GETTING STARTED

CHAPTER 1 GETTING STARTED GETTING STARTED WITH EXCEL CHAPTER 1 GETTING STARTED Microsoft Excel is an all-purpose spreadsheet application with many functions. We will be using Excel 97. This guide is not a general Excel manual,

More information

Copyright (c) by Matthew S. Harris

Copyright (c) by Matthew S. Harris Documentation & How-To Didjiman's Forms Instance Manager Class For MS Access 2007 and Higher Version v2017-03-28 Copyright (c) 2014-2017 by Matthew S. Harris Permission is granted to copy, distribute and/or

More information

How to Compare Two Lists or Columns in Excel

How to Compare Two Lists or Columns in Excel While doing different tasks in Excel we often come across a situation where the matching and differences of two or multiple columns are required. It s not a difficult task to find the differences and matches

More information

Structured Solutions Inc. Tools MS Project to Excel Export/Import Tools

Structured Solutions Inc. Tools MS Project to Excel Export/Import Tools Structured Solutions Inc. Tools MS Project to Excel Export/Import Tools This Macro Enabled Excel workbook contains a collection of useful tools that enables the user to Get, Post or Lookup data from MS

More information

Visual Basic for Applications

Visual Basic for Applications Visual Basic for Applications Programming Damiano SOMENZI School of Economics and Management Advanced Computer Skills damiano.somenzi@unibz.it Week 1 Outline 1 Visual Basic for Applications Programming

More information

Excel Level 3 - Advanced

Excel Level 3 - Advanced Excel Level 3 - Advanced Introduction This document covers some of the more advanced features of Excel. Spreadsheets can be used in such a multiplicity of ways that it cannot hope to even touch on all

More information

VBA Excel 2013/2016. VBA Visual Basic for Applications. Learner Guide

VBA Excel 2013/2016. VBA Visual Basic for Applications. Learner Guide VBA Visual Basic for Applications Learner Guide 1 Table of Contents SECTION 1 WORKING WITH MACROS...5 WORKING WITH MACROS...6 About Excel macros...6 Opening Excel (using Windows 7 or 10)...6 Recognizing

More information

6/14/2010. VBA program units: Subroutines and Functions. Functions: Examples: Examples:

6/14/2010. VBA program units: Subroutines and Functions. Functions: Examples: Examples: VBA program units: Subroutines and Functions Subs: a chunk of VBA code that can be executed by running it from Excel, from the VBE, or by being called by another VBA subprogram can be created with the

More information

Appendix III. Installing the Microsoft Excel Add-in For the Freeway Service Patrol Beat Evaluation Model

Appendix III. Installing the Microsoft Excel Add-in For the Freeway Service Patrol Beat Evaluation Model Appendix III Installing the Microsoft Excel Add-in For the Freeway Service Patrol Beat Evaluation Model 1. Introduction and Background In previous releases, the FSP Beat Evaluation (FSPE) Model has been

More information

Introduction to macros

Introduction to macros L E S S O N 7 Introduction to macros Suggested teaching time 30-40 minutes Lesson objectives To understand the basics of creating Visual Basic for Applications modules in Excel, you will: a b c Run existing

More information

KEYWORDS DDE GETOBJECT PATHNAME CLASS VB EDITOR WITHEVENTS HMI 1.0 TYPE LIBRARY HMI.TAG

KEYWORDS DDE GETOBJECT PATHNAME CLASS VB EDITOR WITHEVENTS HMI 1.0 TYPE LIBRARY HMI.TAG Document Number: IX_APP00113 File Name: SpreadsheetLinking.doc Date: January 22, 2003 Product: InteractX Designer Application Note Associated Project: GetObjectDemo KEYWORDS DDE GETOBJECT PATHNAME CLASS

More information

Hiding or Discarding Insignificant Rows in a Report Template

Hiding or Discarding Insignificant Rows in a Report Template Hiding or Discarding Insignificant Rows in a Report Template Objective: This lesson will familiarize you with the following: what the ZeroingII add-in function is how to prepare your report to use the

More information

CSE 123 Introduction to Computing

CSE 123 Introduction to Computing CSE 123 Introduction to Computing Lecture 6 Programming with VBA (Projects, forms, modules, variables, flowcharts) SPRING 2012 Assist. Prof. A. Evren Tugtas Starting with the VBA Editor Developer/Code/Visual

More information

Sébastien Mathier wwwexcel-pratiquecom/en Variables : Variables make it possible to store all sorts of information Here's the first example : 'Display the value of the variable in a dialog box 'Declaring

More information

MIS0855: Data Science In-Class Exercise for Mar Creating Interactive Dashboards

MIS0855: Data Science In-Class Exercise for Mar Creating Interactive Dashboards MIS0855: Data Science In-Class Exercise for Mar 25-27 Creating Interactive Dashboards Objective: Create a dashboard with interactive data filtering using Tableau Learning Outcomes: Understand how to create

More information

Civil Engineering Computation

Civil Engineering Computation Civil Engineering Computation First Steps in VBA Homework Evaluation 2 1 Homework Evaluation 3 Based on this rubric, you may resubmit Homework 1 and Homework 2 (along with today s homework) by next Monday

More information

Advanced Financial Modeling Macros. EduPristine

Advanced Financial Modeling Macros. EduPristine Advanced Financial Modeling Macros EduPristine www.edupristine.com/ca Agenda Introduction to Macros & Advanced Application Building in Excel Introduction and context Key Concepts in Macros Macros as recorded

More information

Learning Excel VBA. About Variables. ComboProjects. Prepared By Daniel Lamarche

Learning Excel VBA. About Variables. ComboProjects. Prepared By Daniel Lamarche Learning Excel VBA About Variables Prepared By Daniel Lamarche ComboProjects About Variables By Daniel Lamarche (Last update February 2017). The term variables often send shivers in the back of many learning

More information

Separate, Split & Remove Substring & Number from Text with Excel Functions & VBA

Separate, Split & Remove Substring & Number from Text with Excel Functions & VBA [Editor s Note: This is a guide on how to separate, split & remove substring & numbers from text using Excel Functions and VBA. Examples of substring functions are CHAR, FIND, LEFT, LOWER, MID, PROPER,

More information

Ms Excel Vba Continue Loop Through Range Of

Ms Excel Vba Continue Loop Through Range Of Ms Excel Vba Continue Loop Through Range Of Rows Learn how to make your VBA code dynamic by coding in a way that allows your 5 Different Ways to Find The Last Row or Last Column Using VBA In Microsoft

More information

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials Fundamentals We build up instructions from three types of materials Constants Expressions Fundamentals Constants are just that, they are values that don t change as our macros are executing Fundamentals

More information

Depiction of program declaring a variable and then assigning it a value

Depiction of program declaring a variable and then assigning it a value Programming languages I have found, the easiest first computer language to learn is VBA, the macro programming language provided with Microsoft Office. All examples below, will All modern programming languages

More information

VISUAL BASIC 2 EDITOR

VISUAL BASIC 2 EDITOR VISUAL BASI 2 EDITOR hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Objectives You will learn: How to edit code in the. How to create, open, and access project(s). How to edit scripts and use the code

More information

Workbooks (File) and Worksheet Handling

Workbooks (File) and Worksheet Handling Workbooks (File) and Worksheet Handling Excel Limitation Excel shortcut use and benefits Excel setting and custom list creation Excel Template and File location system Advanced Paste Special Calculation

More information

Lastly, in case you don t already know this, and don t have Excel on your computers, you can get it for free through IT s website under software.

Lastly, in case you don t already know this, and don t have Excel on your computers, you can get it for free through IT s website under software. Welcome to the EASE workshop series, part of the STEM Gateway program. Before we begin, I want to make sure we are clear that this is by no means meant to be an all inclusive class in Excel. At each step,

More information

Building a game of Tetris #1 the generation and the rotation of the Tetris parts

Building a game of Tetris #1 the generation and the rotation of the Tetris parts Building a game of Tetris # the generation and the rotation of the Tetris parts by George Lungu - This tutorial explains the creation of a game of Tetris in Excel using spreadsheet formulas and minimum

More information

Applications Development

Applications Development AD003 User Implementation and Revision of Business Rules Without Hard Coding: Macro-Generated SAS Code By Michael Krumenaker, Sr. Project Manager, Palisades Research, Inc. and Jit Bhattacharya, Manager

More information

BASIC MACROINSTRUCTIONS (MACROS)

BASIC MACROINSTRUCTIONS (MACROS) MS office offers a functionality of building complex actions and quasi-programs by means of a special scripting language called VBA (Visual Basic for Applications). In this lab, you will learn how to use

More information

Using Microsoft Excel

Using Microsoft Excel Using Microsoft Excel Formatting a spreadsheet means changing the way it looks to make it neater and more attractive. Formatting changes can include modifying number styles, text size and colours. Many

More information

VBA Foundations, Part 12

VBA Foundations, Part 12 As quickly as you can Snatch the Pebble from my hand, he had said as he extended his hand toward you. You reached for the pebble but you opened it only to find that it was indeed still empty. Looking down

More information

Visual basic tutorial problems, developed by Dr. Clement,

Visual basic tutorial problems, developed by Dr. Clement, EXCEL Visual Basic Tutorial Problems (Version January 20, 2009) Dr. Prabhakar Clement Arthur H. Feagin Distinguished Chair Professor Department of Civil Engineering, Auburn University Home page: http://www.eng.auburn.edu/users/clemept/

More information

IP4 - Running reports

IP4 - Running reports To assist with tracking and monitoring HRIS recruitment and personnel, reports can be run from Discoverer Plus. This guide covers the following process steps: Logging in... 2 What s changed? Changed reference

More information

1. Introduction to Microsoft Excel

1. Introduction to Microsoft Excel 1. Introduction to Microsoft Excel A spreadsheet is an online version of an accountant's worksheet, which can automatically do most of the calculating for you. You can do budgets, analyze data, or generate

More information

MICROSOFT EXCEL 2000 LEVEL 5 VBA PROGRAMMING INTRODUCTION

MICROSOFT EXCEL 2000 LEVEL 5 VBA PROGRAMMING INTRODUCTION MICROSOFT EXCEL 2000 LEVEL 5 VBA PROGRAMMING INTRODUCTION Lesson 1 - Recording Macros Excel 2000: Level 5 (VBA Programming) Student Edition LESSON 1 - RECORDING MACROS... 4 Working with Visual Basic Applications...

More information

Insert Page Break Excel 2007 Not Working >>>CLICK HERE<<<

Insert Page Break Excel 2007 Not Working >>>CLICK HERE<<< Insert Page Break Excel 2007 Not Working Page breaks not appearing where you expect them in your subtotaled data? If you are using a later version (Excel 2007 or later), this tip may not work for you.

More information

Enjoy Microsoft Excel 2007 for Novice Users Author: Christine Kent Web address Blog address address

Enjoy Microsoft Excel 2007 for Novice Users Author: Christine Kent Web address Blog address  address Enjoy Microsoft Excel 2007 for Novice Users Copyright Christine Kent, September 2008 Author: Christine Kent Web address www.christinekent.net Blog address http://christinekent.blogspot.com/ Email address

More information

CS 155 Exam 2 Spring 2015

CS 155 Exam 2 Spring 2015 CS 155 Exam 2 Spring 2015 Name (print): Instructions: Keep your eyes on your own paper, and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than the professor/proctor

More information

Unit 7. Lesson 7.1. Loop. For Next Statements. Introduction. Loop

Unit 7. Lesson 7.1. Loop. For Next Statements. Introduction. Loop Loop Unit 7 Loop Introduction So far we have seen that each instruction is executed once and once only. Some time we may require that a group of instructions be executed repeatedly, until some logical

More information

EXCEL WORKSHOP III INTRODUCTION TO MACROS AND VBA PROGRAMMING

EXCEL WORKSHOP III INTRODUCTION TO MACROS AND VBA PROGRAMMING EXCEL WORKSHOP III INTRODUCTION TO MACROS AND VBA PROGRAMMING TABLE OF CONTENTS 1. What is VBA? 2. Safety First! 1. Disabling and Enabling Macros 3. Getting started 1. Enabling the Developer tab 4. Basic

More information

Sébastien Mathier www.excel-pratique.com/en Selections : We'll begin by creating a macro that selects the cell that we specifiy. First open the editor and add a module : In the module, type "sub selection"

More information

Intelligence. Peachtree Business Intelligence Report Writing Best Practices

Intelligence. Peachtree Business Intelligence Report Writing Best Practices Intelligence Peachtree Business Intelligence Report Writing Best Practices 1. GETTING STARTED... 3 1.1. PRE-REQUISITES... 3 2. CONNECTOR TOOL... 4 2.1. CONTAINERS:... 4 2.2. JOINS:... 4 2.3. EXPRESSIONS:...

More information

CSE 123 Introduction to Computing

CSE 123 Introduction to Computing CSE 123 Introduction to Computing Lecture 11 Programming with Arrays SPRING 2012 Assist. Prof. A. Evren Tugtas Array Variables Review For detailed information on array variables look at the notes of Lecture

More information

Top 20 Excel Limitations that might Frustrate You!

Top 20 Excel Limitations that might Frustrate You! Excel is obviously one of the most important products in the world. It is very helpful in managing, analyzing data. But there is also something that may get us frustrated when using Excel. Today I d like

More information

The Microsoft Excel Course is divided into 4 levels

The Microsoft Excel Course is divided into 4 levels MS Excel is a very powerful tools used by most of the data analyst in the industry. In this course you will learn how to Master Excel and make it perform any kind of data analysis and Visualization. You

More information

A Product of. Structured Solutions Inc.

A Product of. Structured Solutions Inc. SSI Tools Time Scaled Values Analysis Tools Structured Solutions Inc. www.ssitools.com A Product of Structured Solutions Inc. 1 Modify The Columns in the Sheet Named Template SSI Status Workbook Template

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #16 Loops: Matrix Using Nested for Loop

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #16 Loops: Matrix Using Nested for Loop Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #16 Loops: Matrix Using Nested for Loop In this section, we will use the, for loop to code of the matrix problem.

More information

FAQ: Advanced Functions

FAQ: Advanced Functions Question 1: What are formulas and functions? Answer 1: Formulas are a type of data that can be entered into a cell in Excel. Formulas begin with an equal sign and use mathematical operators to calculate

More information

2. INTRODUCTORY EXCEL

2. INTRODUCTORY EXCEL CS130 - Introductory Excel 1 2. INTRODUCTORY EXCEL Fall 2017 CS130 - Introductory Excel 2 Introduction to Excel What is Microsoft Excel? What can we do with Excel? CS130 - Introductory Excel 3 Launch Excel

More information

BaSICS OF excel By: Steven 10.1

BaSICS OF excel By: Steven 10.1 BaSICS OF excel By: Steven 10.1 Workbook 1 workbook is made out of spreadsheet files. You can add it by going to (File > New Workbook). Cell Each & every rectangular box in a spreadsheet is referred as

More information

Learning Excel VBA. Using Loops in Your Code. ComboProjects. Prepared By Daniel Lamarche

Learning Excel VBA. Using Loops in Your Code. ComboProjects. Prepared By Daniel Lamarche Learning Excel VBA Using s in Your Code Prepared By Daniel Lamarche ComboProjects Using s in Your Code By Daniel Lamarche (Last update June 2016). s are pretty simple in concept however many new programmers

More information

Instruction Case Vba Excel Between Two Values

Instruction Case Vba Excel Between Two Values Instruction Case Vba Excel Between Two Values The data is gathered between the last day of the billing month or within 7 days of the next. Forum Question Forums Excel Questions, VBA/ Action allowed only

More information

EXAMGOOD QUESTION & ANSWER. Accurate study guides High passing rate! Exam Good provides update free of charge in one year!

EXAMGOOD QUESTION & ANSWER. Accurate study guides High passing rate! Exam Good provides update free of charge in one year! EXAMGOOD QUESTION & ANSWER Exam Good provides update free of charge in one year! Accurate study guides High passing rate! http://www.examgood.com Exam : IC3-2 Title : IC3 Key Applications Version : DEMO

More information

MgtOp 470 Business Modeling with Spreadsheets Sample Midterm Exam. 1. Spreadsheets are known as the of business analysis.

MgtOp 470 Business Modeling with Spreadsheets Sample Midterm Exam. 1. Spreadsheets are known as the of business analysis. Section 1 Multiple Choice MgtOp 470 Business Modeling with Spreadsheets Sample Midterm Exam 1. Spreadsheets are known as the of business analysis. A. German motor car B. Mexican jumping bean C. Swiss army

More information

Customizing the Excel 2013 program window. Getting started with Excel 2013

Customizing the Excel 2013 program window. Getting started with Excel 2013 Customizing the Excel 2013 program window 1 2 Getting started with Excel 2013 Working with data and Excel tables Creating workbooks Modifying workbooks Modifying worksheets Merging and unmerging cells

More information

Microsoft Excel 2007 Macros and VBA

Microsoft Excel 2007 Macros and VBA Microsoft Excel 2007 Macros and VBA With the introduction of Excel 2007 Microsoft made a number of changes to the way macros and VBA are approached. This document outlines these special features of Excel

More information

Microsoft Excel 2007

Microsoft Excel 2007 Learning computers is Show ezy Microsoft Excel 2007 301 Excel screen, toolbars, views, sheets, and uses for Excel 2005-8 Steve Slisar 2005-8 COPYRIGHT: The copyright for this publication is owned by Steve

More information

OBJECT ORIENTED PROGRAMMING: VBA

OBJECT ORIENTED PROGRAMMING: VBA Agenda for Today VBA and Macro creation (using Excel) DSC340 Object-Oriented Programming Creating Macros with VBA Mike Pangburn What is O-O programming? OBJECT ORIENTED PROGRAMMING: VBA A programming style

More information

COURSE OUTLINE MS Excel 2013 Level 1 Last Updated: 5 August 2016

COURSE OUTLINE MS Excel 2013 Level 1 Last Updated: 5 August 2016 Last Updated: 5 August 2016 1. Table of Contents 1. Table of Contents... 2 A. S... 3 1. Free online pre-training assessments... 3 2.... 3 B. CONTACT DETAILS... 6 1. Location for training... 6 2. For bookings

More information

This Week. Trapezoidal Rule, theory. Warmup Example: Numeric Integration. Trapezoidal Rule, pseudocode. Trapezoidal Rule, implementation

This Week. Trapezoidal Rule, theory. Warmup Example: Numeric Integration. Trapezoidal Rule, pseudocode. Trapezoidal Rule, implementation This Week ENGG8 Computing for Engineers Week 9 Recursion, External Application Interfacing Monday: numeric integration example, then first part of the material Wednesday 9am: rest of the new material Wednesday

More information

Sage Intelligence: Report Writing Methodology Agenda

Sage Intelligence: Report Writing Methodology Agenda Sage Intelligence: Report Writing Methodology Agenda Report Structure Report Writing Methodology Report Writing Best Practices The purpose of this webinar is to provide the best possible guidelines on

More information

ENGG1811 Computing for Engineers Week 10 Recursion, External Application Interfacing

ENGG1811 Computing for Engineers Week 10 Recursion, External Application Interfacing ENGG1811 Computing for Engineers Week 10 Recursion, External Application Interfacing ENGG1811 UNSW, CRICOS Provider No: 00098G W10 slide 1 This Week Wednesday am: Will include discussion about assignment

More information

Open a new Excel workbook and look for the Standard Toolbar.

Open a new Excel workbook and look for the Standard Toolbar. This activity shows how to use a spreadsheet to draw line graphs. Open a new Excel workbook and look for the Standard Toolbar. If it is not there, left click on View then Toolbars, then Standard to make

More information

d2vbaref.doc Page 1 of 22 05/11/02 14:21

d2vbaref.doc Page 1 of 22 05/11/02 14:21 Database Design 2 1. VBA or Macros?... 2 1.1 Advantages of VBA:... 2 1.2 When to use macros... 3 1.3 From here...... 3 2. A simple event procedure... 4 2.1 The code explained... 4 2.2 How does the error

More information

1. Position your mouse over the column line in the column heading so that the white cross becomes a double arrow.

1. Position your mouse over the column line in the column heading so that the white cross becomes a double arrow. Excel 2010 Modifying Columns, Rows, and Cells Introduction Page 1 When you open a new, blank workbook, the cells are set to a default size.you do have the ability to modify cells, and to insert and delete

More information

Unit 6 - Software Design and Development LESSON 3 KEY FEATURES

Unit 6 - Software Design and Development LESSON 3 KEY FEATURES Unit 6 - Software Design and Development LESSON 3 KEY FEATURES Last session 1. Language generations. 2. Reasons why languages are used by organisations. 1. Proprietary or open source. 2. Features and tools.

More information

Extending the Unit Converter

Extending the Unit Converter Extending the Unit Converter You wrote a unit converter previously that converted the values in selected cells from degrees Celsius to degrees Fahrenheit. You could write separate macros to do different

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #17. Loops: Break Statement

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #17. Loops: Break Statement Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #17 Loops: Break Statement (Refer Slide Time: 00:07) In this session we will see one more feature that is present

More information

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6)

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) Technology & Information Management Instructor: Michael Kremer, Ph.D. Database Program: Microsoft Access Series DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) AGENDA 3. Executing VBA

More information

VBA Collections A Group of Similar Objects that Share Common Properties, Methods and

VBA Collections A Group of Similar Objects that Share Common Properties, Methods and VBA AND MACROS VBA is a major division of the stand-alone Visual Basic programming language. It is integrated into Microsoft Office applications. It is the macro language of Microsoft Office Suite. Previously

More information