Beruflich Dokumente
Kultur Dokumente
Formatting, VBA
ME 325
Spring, 2007
Overview
• Formulas and Functions
• Formatting
• Printing
• Macros/VBA
Excel Formula
• A formula consist of one or many
expressions, such as cells arithmetic
and built in or user defined functions
• In Excel, formulas always begin with an
equal sign (=).
• Ex. =A1+2*B6+Sum(C2:C10)
Excel Functions
• Excel supplies more than 350 functions
organized into 10 categories:
– Database, Date and Time, Engineering, Financial,
Information, Logical, Lookup, Math, Text and Data,
and Statistical functions
• You can use the Insert Function button on the
Formula bar to select from a list of functions.
• A series of dialog boxes will assist you in
filling in the arguments of the function and
this process also enforces the use of proper
syntax.
Relative Reference
• A relative reference is a cell reference
that shifts when you copy it to a new
location on a worksheet.
• A relative reference changes in relation
to the change of location.
• If you copy a formula to a cell three
rows down and five columns to the
right, a relative reference to cell B5 in
the source cell would become G8 in the
destination cell.
Absolute Reference
• An absolute reference is a cell
reference that does not change when
you copy the formula to a new location.
• To create an absolute reference, you
preface the column and/or row
designations with a dollar sign ($).
• For example, the absolute reference for
B5 would be $B$5.
• This cell reference would stay the same
no matter where you copied the
Insert Function Wizard
• To get help from Excel to insert a
function, first click the cell in which you
wish to insert the function.
row=startRow
Do
x=Cells(row,”A”).Value
y=Exp(x)*Sin(2*x)-3.25
Cells(row,”B”).Value=y
row=row+1
Loop Until row >(startRow+nRows)
For … Next Loop
Sub FillData(startRow,nRows)
Dim x as Double
Dim y as Double
For row=startRow to
(startRow+nRows)
x=Cells(row,”A”).Value
y=Exp(x)*Sin(2*x)-3.25
Cells(row,”B”).Value=y
The If...Then...ElseIf
Statement
If Condition1 is True Then
Statement1
ElseIf Condition2 is True Then
Statement2
ElseIf Conditionk is True Then
Statementk
End If
If Then …
Function MyFunction(x)
retVal=“N/A”
If x <10 Then
retVal=“Less Than 10”
ElseIf x<20
retVal=“10 to 20”
Else
retVal=“More Than 20”
End If
MyFunction=retVal
End Function
The Select Case Statement
Select Case Expression
Case Expression1
Statement1
Case Expression2
Statement2
Case Expressionk
Statementk
Case Else
Default statement
End Select