CS代写 PowerPoint Presentation

PowerPoint Presentation

Chapter 36: User-Defined Functions with VBA

Copyright By PowCoder代写 加微信 powcoder

Visual Basic for Applications (VBA)
VBA is Excel’s programming language
Complete programming language and environment fully integrated into Excel (and other Microsoft Office applications)
To access VBA, Open Developer tab | Visual Basic Editor
Got to File|Options|Customize the Ribbon and indicate Developer
Save Excel file with VBA functions as Excel Macro-Enabled Workbook (.xlsm)
Comments: VBA will ignore anything on a line which follows an apostrophe (‘)

Visual Basic for Applications (VBA)

VBA window:

Visual Basic for Applications (VBA)
VBA Insert | Module window:

Visual Basic for Applications (VBA)
Begin writing function:

VBA If Statement (Plus function)
Parameter1 3
Parameter2 2
Plus 5 =plus(B2,B3)

VBA: If Statement
OneLineIf:
10 1 =OneLineIf(A13)

VBA: BlockIf Statement

-3 -1 =BlockIf(A18)

VBA: NestedIf Statement

11 6 1 =NestedIf(A23,B23)

Boolean and Comparison Operators
Boolean expression:
TRUE when condition holds
FALSE when condition is violated
Comparison operators:

VBA: AND Boolean operator
And Boolean operator:
parameter1 parameter2
9 14 12 =AndDemo(A33,b33)

VBA: Or Boolean operator

Or Boolean operator:
parameter1 parameter2
9 14 3 =OrDemo(A43,B43)
11 14 12 * both conditions are not met

VBA: Loops – Do While

Loops: DoWhile
5 120 =DoWhileDemo(A49)
9 362,880
13 6,227,020,800

VBA: Loops – Do Loop While

Loops: DoLoopsWhile
5 120 =DoLoopWhileDemo(A54)
9 362,880
13 6,227,020,800

VBA: Loops – Do Until

Loop: Do Until
5 120 =DoUntilDemo(A59)
9 362,880
13 6,227,020,800

VBA: Loops – Do Loop Until
Loop: Do Loop Until
5 120 =DoLoopUntilDemo(A64)
9 362,880
13 6,227,020,800

VBA: Loops – For (Positive Step argument)
Loop: For (Step function postive)
5 120 =ForDemo1(A69)
9 362,880
13 6,227,020,800

VBA: Loops – For (Negative Step argument)

Loop: For (Step function negative)
5 120 =fordemo2(A74)
9 362,880
13 6,227,020,800

VBA: Loops – Exit For

Parameter1 Parameter2
5 22 15 =exitfordemo(A80,B80)

VBA: Using Excel functions
Using Excel functions in VBA
Binomial 0.205078125 =binomial(B79,B80,B81)

/docProps/thumbnail.jpeg

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com