You are on page 1of 20

Chapter 8.

Formulas and
Other Objects
BMGT 302
Business Application
Programming
Scott Hudson

Relative Referencing and Absolute


Referencing
There are four basic types of referencing
Relative Referencing: Row and column value will change
(B2).
Absolute Referencing: Neither row nor column value will
change ($B$2).
Row Absolute: Row value does not change, but column value
will change (B$2).
Column Absolute: Column value does not change, but row
value will change ($B2).
Scott Hudson BMGT302

The SUM function is


entered in column B16
using relative
referencing:
=SUM(B4:B13)
When the function is
copied to cell C16, the
function values shift
relative to the new
position

Scott Hudson BMGT302

In cell E11, the sum


from cell B16 is
multiplied by the
value in cell E4:
=E4*B16
Copying this formula
to cell F11, does NOT
yield E4*C16, but
rather F4*C16

Scott Hudson BMGT302

Absolute referencing will keep E4


constant in both formulas: $E$4*B16
and $E$4*C16.

Scott Hudson BMGT302

Referencing (contd)
Row absolute referencing places the $ in
front of the row number
column letter $ row number
A$1

Column absolute referencing places the $ in


front of the column letter
$ column letter row number
$A2
Scott Hudson BMGT302

Numbers in row headings are same as column


headings and we want one row number multiplied
by one column number.
Open File Referencing.xlsx

When the formula is copied, only the column of the


row absolute value will change and only the row of
the column absolute value will change

Scott Hudson BMGT302

A1 and R1C1 References

In R1C1 style, R stands for row and C stands for column. For example,
cell D7 is identified by Excel as the address at the intersection of row 7
and column 4 (R7C4).
the R1C1 address of cell A1 is R1C1
Scott Hudson BMGT302

Referencing in R1C1
Relative Referencing
Mixed Referencing

Absolute referencing

Scott Hudson BMGT302

Comparison

Scott Hudson BMGT302

10

Toggling between A1 and R1C1 Style

Scott Hudson BMGT302

11

R1C1 in absolute referencing

Scott Hudson BMGT302

12

Value
End With
Appl icat ion. ScreenUpdating
End sub
True

Fill Empty Cells with the Value from Above

Scott Hudson BMGT302

13

Relative, Mixed, and Absolute References

B2 is the named range OvertimeFactor


Cell D5:
=IF(B5<=$B$1,B5*C5,SUM((B5-$B$1) *OvertimeFactor,
$B$1)*C5)
Scott Hudson BMGT302

14

Scott Hudson BMGT302

15

Common Objects
Workbook
Properties: Path, Name, FileFormat, ReadOnly, Saved,
Methods: Open, Close, Save, SaveAs,

Worksheet
Properties: CodeName(aka Permanent Name), Name,
Methods: Select, Copy, Paste, PasteSpecial, Delete, Move,

Range

Chart
Properties: Name, ChartType, HasLegend, HasTitle,
ChartTitle,
Methods: Select, Activate, Copy, Paste, Delete, Move,
Scott Hudson BMGT302

16

Common Collections
Workbooks
Properties: Count, Item,
Methods: Add, Open, Close,

Worksheets
Properties: Count, Item,
Methods: Add, Copy, Delete, Move, Select,

Charts
Properties: Count, Item,
Methods: Add, Copy, Delete, Move, Select,
Scott Hudson BMGT302

17

Workbooks and Worksheets Collections


Workbooks collection consists of Workbook
objects.
Any particular Workbook object contains a
Worksheets collection and a Charts collection.
Adds a new worksheet to the active workbook, and
names this new sheet NewData:
ActiveWorkbook.Worksheets.Add
ActiveSheet.Name = "NewData"

Creates a variable referring to this new worksheet:


Dim ws As Worksheet
Set ws = Worksheets("NewData")
Scott Hudson BMGT302

18

WorkBooks Examples
Open Workbooks.xlsm

Scott Hudson BMGT302

19

WorkSheets Examples
Open Worksheets.xlsm

Scott Hudson BMGT302

20

You might also like