Week 3.  Assessed Exercise 1  Working with ranges.

Slides:



Advertisements
Similar presentations
Introduction to Excel This class is “HANDS-ON” you will need to open up an excel spreadsheet and do examples as you go along. Students will be able to.
Advertisements

An Introduction to Spreadsheets Using Number Magic Malcolm Wilson ICT Curriculum Support Teacher (Primary) Falkirk Council.
CP212 Midterm Review Original on Google Drive. *Omas Abdullah: My Life and the Oculus Rift* Featuring discussion of new age technologyused for gaming.
Microsoft Office XP Microsoft Excel
Object Oriented Programming A programming concept which views programs as objects with properties and ways to manipulate the object and the properties.
Chapter 13: More on Objects Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
More on Cell and Range References. n A reference identifies a cell or a range of cells on a worksheet and tells Microsoft Excel where to look for the.
3-dimensional formula A formula that refers to cells in other worksheets.
Understanding Microsoft Excel
Collin College Excel Exam Review. True In Excel worksheets, rows are designated using numbers while columns are designated using letters.
CPSC 203 Introduction to Computers T97 TA: Jie (Jeff) Gao.
BCIS IB, (Test 1) Excel Lessons 1, 2 and 3 Press Space bar to Advance Frame.
Working with Large Worksheets, Charting, and What-If Analysis
BY: T. KHAWLAH AL-MUTLAQ Excel Web App. Introduction to Spreadsheets 2 A spreadsheet is an electronic file used to organize related data and perform calculations.
MICROSOFT OFFICE 2013 EXCEL 1. 2 File Tab 1 Title Bar 5. Group 7 Name Box 6 Active Cell 8 Formula Bar 4 Ribbon 9 Column 10. Row 11 Sheet Tabs 12 View.
L13_2 Microsoft Excel - Formulas, Formatting and Creating Charts * Entering the Titles and Numbers into the Worksheet * Entering Formulas * Entering Formulas.
Chapter 1 Introduction to Spreadsheet. Agenda Download the practice files Spreadsheet application Workbook and worksheet Toolbar Cell Formatting Printing.
1 CS110: Lecture 2 Spreadsheets Prepared by Fred Annexstein University of Cincinnati CC Some rights reserved Today’s Topics Basics of Excel Spreadsheets.
FIRST COURSE Excel Lecture. XP 2 Introducing Excel Microsoft Office Excel 2007 (or Excel) is a computer program used to enter, analyze, and present quantitative.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
EXCEL INTERMEDIATE 1. WORKSHEETS Worksheet Tabs –Rename by double clicking –Can be moved by click and drag –Change colour by right click and choose Tab.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #3: Manipulating Excel Objects IE 212: Computational Methods for Industrial Engineering.
Lesson 1 – Microsoft Excel The goal of this lesson is for students to successfully explore and describe the Excel window and to create a new worksheet.
Microsoft Excel Diane M. Coyle Spring 2009 CS 105.
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.
12. Visual Basic If Statements and Do Loops. Open 12b-datastart.xlsm.
Introduction to Spreadsheet Software. Spreadsheets and Their Uses Examples of Charts Spreadsheet Basics Spreadsheet Map Types of Spreadsheet Data Navigating.
University of Toronto at Scarborough © Andria Hunter, Kersti Wain-Bantin CSCA01 VBA 1 Lecture Outline Record macro and examine VBA code VBA Editor (IDE)
CIS111 Basic PC Literacy Formatting a Worksheet Pages
ELECTRONIC SPREADSHEET Chang-Yang Lin Eastern Kentucky University.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 1 Copyright © 2008 Prentice-Hall. All rights reserved. What Can I Do with a Spreadsheet.
Cell Alignment By default, text is left aligned and values are right aligned. You can also adjust vertical alignment.
Visual Basic for Applications Macro Programming For Microsoft Office.
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.
Microsoft Excel. Excel specializes in creating and designing spreadsheets, or worksheets Worksheet – area to insert data Workbook – a set of worksheets.
Chapter 1 Creating a Worksheet and a Chart
Lab 4 Range Review, Control Logic and Loops ► Range Review ► Control Logic and Loops ► Exercise.
Chapter 9 Macros And Visual Basic For Applications.
Worksheets Copyright 2006 South-Western/Thomson Learning.
Lesson 1 – Microsoft Excel * The goal of this lesson is for students to successfully explore and describe the Excel window and to create a new worksheet.
Chapter 13: More on Objects Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Lab 2 Introduction to VBA (II) ► Lab 1 revisited - Sub & Function procedures - Data types and variable declaration ► Recording.
Microsoft Excel. Excel specializes in creating and designing spreadsheets, or worksheets Worksheet – area to insert data Workbook – a set of worksheets.
Lab 6 (2) Arrays ► Lab 5 (1) Exercise Review ► Array Concept ► Why Arrays? ► Array Declaration ► An Example of Array ► Exercise.
Lesson 6 Formatting Cells and Ranges. Objectives:  Insert and delete cells  Manually format cell contents  Copy cell formatting with the Format Painter.
Introduction to Spreadsheets A spreadsheet is an electronic file used to organize related data and perform calculations. Example- Microsoft Excel. 1.
VBA Navigation, Conditionals, and Boxes. VBA Navigation.
Understanding Microsoft Excel Lesson 1 – Microsoft Excel 2013.
Financial Information Management VB, VBA, VS, VSTO & VBE: Putting it all together Source: Excel VBA Programming by John Walkenbach.
Lab 5 Arrays ► Lab 4 Exercise Review ► Array Concept ► Why Arrays? ► Array Declaration ► An Example of Array ► Exercise.
VBA Programming for Excel Review Excel Objects Excel Methods Identifying Specific Cells Review Functions for Excel Custom Menus.
Understanding Microsoft Excel
Understanding Microsoft Excel
Basic Editing Functions
Created by Stacey Wilson
SPREADSHEETS – MICROSOFT EXCEL
Microsoft Excel Basic Skills
Computer Fundamentals
Lessons Vocabulary Excel 2016.
Learning Excel Session 9 and 10 Dr. Chaitali Basu Mukherji.
Unit 42 : Spreadsheet Modelling
Excel 1 Microsoft Office 2013.
Understanding Microsoft Excel
Exploring Microsoft Excel
Understanding Microsoft Excel
Lesson 1 - Automating Tasks
Activate a range and manipulating activated range
Spreadsheets and Data Management
Microsoft Excel 2007 – Level 2
Presentation transcript:

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 in Excel are range operations. Select, copy, format, enter values or formulas  Important to automate range operations with VBA.  Ranges can be absolute or relative  The Range object has properties and methods.  Use the Object Browser in the VBE to look up any specific property or method.  For more examples of ranges in VBA look at the examples in the file Ranges.xls. 4

 Use an address Follow Range with an address in double quotes: Range(“A1:A10”)  Use a range name Follow Range with the range name in double quotes: Range(“Sales”)  Use the Offset property  Use a Range object variable  Use the End property (xlDown, xlUp, xlToRight, xlToLeft) You do not need to know the size of the range 5

 You can refer to a range literally, using the Excel cell references in double quotes:  MsgBox Range("B1:F1").Address  MsgBox "The first score for the first employee is " & Range("B2").Value

 You can apply a name to a range: Range("B1:F1").Name = "ScoreNames“  Then use the range: Range(“ScoreNames").Font.Bold = True  And remove names: ActiveWorkbook.Names("ScoreNames").Delete

You can refer to cells within a named range: Range("B2:F19").Name = "ScoreData“ MsgBox Range(“ScoreData”).Cells(2,3).Value (returns the value in D3)

 Select Select method is like highlighting  Range(“B2:F5”).Select  Activate Makes this cell “live” (only works on a single cell range, does not affect any “selection”)  Range(“E3”).Activate Can activate a workbook or worksheet  Worksheets(“Practice2”).Activate  As seen with macros can use “ActiveCell” and “Selection” as handles

 Offset(rows,cols) is a property that allows you to refer to a cell offset from a range.  For example:  Activecell.offset(rows,cols); or  Selection.offset(rows,cols); or  Range("D12").offset(rows,cols)  Use with ActiveCell and with.End(xldown)

 By using A1 as an anchor, all the offset property can be used where the actual range is unknown or variable With Range("A1") Range(.Offset(0, 1),.Offset(0,1).End(xlToRight)).Name = _ "ScoreNames" Range(.Offset(1, 0),.Offset(1,0).End(xlDown)).Name = _ "EmployeeNumbers" Range(.Offset(1, 1),.Offset(1,1).End(xlDown).End(xlToRight)).Name = _ "ScoreData" End With

 You can refer to columns or rows either in reference to the whole sheet or to a range or selection – for example, Columns(2).select is as follows:  The principle is the same for Rows. Rows(3) is the 3 rd row in the sheet.

This sub formats the cells in the range ScoreNames. Using “With” avoids repetition With Range("ScoreNames").HorizontalAlignment = xlRight.Interior.ColorIndex = 5 With.Font.Bold = True.ColorIndex = 3.Size = 16 End With.EntireColumn.AutoFit End With

 Formulas Range(“B20”).Formula =“=AVERAGE(B2:B19)” Range(“B20”).FormulaR1C1 = "=AVERAGE(R[-18]C:R[-1]C)" Note R1C1 notation See Range9 for an example of applying a formula to several cells (like using autofill)

ActiveSheet.Rows(Rows.Count).Select MsgBox Selection.Count Sub Rangetest() MsgBox “The current selection is “ & Selection.Rows.Count & _ “ rows high and” & Selection.Columns.Count & “ columns wide” End Sub Worksheets.count The number of worksheets in a workbook (file) Workbooks.count The number of currently open files Columns.count the number of columns in the current sheet Rows.count the number of rows in the current sheet Cells.count the number of cells in the current sheet

 A region is a range of filled cells, bounded by empty cells. The current region is where the currently selected cell is: it includes all non-blank cells “touching” the current cell.  As long as you have one cell in the region selected, you can press Ctrl-Shift-8 (i.e., Ctrl-*) to select the region  This shortcut key corresponds to a line of code: Selection.CurrentRegion.Select

 Use the wk03empscrnameranges file to complete the following tasks Name cell A1 as Title Name the headings in row 3 as Headings Name the employee numbers in column A as EmpNumbers Name the range of scores as Scores  With reference to the names above write a sub that performs the following tasks: Make cell A1 bold and size 14 Make the headings on row 3 bold, italic and right aligned Change the font colour for the employee numbers in column A to blue Change the background of the scores cells to light grey (Hint: use the Interior property) Enter the label “Averages” in cell A22 and make it bold Enter a formula in B22 that calculates the average. Copy the formula to C22:F22

 For Each Loops

.Cells Used to refer to a particular cell. Range(“A1:A10”).Cells(3) refers to the third cell in the range Range(“A1:A10”).Cells(3,2) refers to the cell in row 3, column 2 .Font Returns a reference to the font of the range. Can change font properties Range(“A1:A10”).Font.Bold = true .Formula Returns or sets a formula in a range as a string. Range(“A11”).Formula = “SUM(A1:A10)” .Interior Returns a reference to the interior of a cell Often used to change background colour Range(“A1:A10”).Interior.Color = vbRed .Name Returns or sets the name of a range. Range(“A1:B10”).Name = “Sales” 19

.Value Returns or sets the value in the cell. Default property for a Range object (can be omitted). Usually used for a single-cell range. unitPrice = Range(“A11”).Value or unitPrice = Range(“A11”) .Offset Returns a reference relative to a range. The range is usually a single cell. Very useful property, used constantly in most applications. It takes two arguments: row offset and column offset. Range(“A5”).Offset(2,3) = start in cell A5, go 2 rows down, 3 columns to the right. Use a positive offset to go down and a negative offset to go up. Use a positive offset to go to the right and a negative offset to go to the left. 20

.Clear Deletes values and formatting from the range. .ClearContents Deletes only values (and formulas). .Copy Copies a range. One optional argument: destination. Range(“A1:B10”).Copy Destination:=Range(“E1:F10”) .Paste Pastes clipboard contents to the range. Can have different arguments indicating how to paste. Range(“E1:F10”).PasteSpecial Paste:=xlPasteValue .Select Selects a range. Equivalent to highlighting a range in Excel. 21