You are on page 1of 79

VBA PPT

VBA

VBA

VB v.s. VBA
VB Visual Basic (
)

VBA Visual Basic for Application (i.e.


Excel Word PowerPoint)
( )

VBA

(Macro)
( ) VBA

VBA
1) A

2)
3) B
4)

VBA

VBA

VBA

VBA

VBA

VBA

CODING

CODING

//

VBA

( )

CODING

VBA (1)

(Integer)
(Double)
(String)
(Boolean)
(Date)
(Variant)

100
1.15

True False
1955/02/24
???

CODING

VBA (2)

CODING

Dim x = 1
Const InterestRate = 0.075
LoanPayoffAmount = 243089
Dim DataEntered As Boolean = False
x=x+1
UserName = Bob Johnson
Date_Started = #3/14/2013#
MyNum = YourNum * 1.25

CODING

HE & LLO HELLO


24\5 4
24 Mod 5 = Mod(24,5) 4

CODING

-1

CODING

-2
A

5*5*5

125

no

&

thing

20

20/3=6...2

20

mod

20/3=62

nothing

CODING

>
<
>=
<=
=
<>

3>2
3<2
3>=2
3<=2
Apple=Cisco
Apple<>Cisco

True
False
True
False
False
True

* Apple>3

CODING

AND (True)
OR
NOT

(True)

CODING

Input
InputBox
( )

CODING

Output
MsgBox
( )

CODING

(1)
1. BMI BMI
Excel

6. ( )
(ex. 1558750 1,558,750)

CODING

(Array)

1 2 3

CODING

VBA

VBA

Range
Range Worksheet
(properties) (methods)
Range(A1:C10); Range(A5); Range(A& myNum);
Range(myRange); Range(3:3); Range(D:D)

VBA

Cells
Cells Cells(Row,Column)
Cells
Range
Range(A1)=Cells(1,1); Range(B,6)=Cells(6,2)

VBA

VBA

Range Cells
1. sheet1 D
2. sheet2
3. Range(B11)=Cells(?,?)
4. Cells(6,9)=Range(?)

VBA

Offset
Offset :

*Range(C4).Offset(2,3)=Range(?)

VBA

Font
Font

VBA

Font
1. Sheet3 (A1:F3)
Ariel
2. QOQ xx.x%

VBA Excel

VBA Excel

VBA
VBEs ToolsOptions Editor tab Auto List
tab

VBA Excel

VBA ( )

VBA Excel

VBA ( )

VBA Excel

VBA ( )

VBA Excel

VBA ( )

VBA Excel

VBA ( )

VBA Excel

1. 3 Show
2. Show

VBA Excel

Excel VBA
WorksheetFunction

VBA Excel

VBA

VBA Excel

VBA

VBA Excel

1. Sheet4 (ID)
( )
2. Show

3. Function Max
Application.WorkSheetFunction.MaxmyMax

VBA

VBA

VBA

VBA

Goto
Goto

VBA

( )

VBA

IfThen ( )
If A is true, than do B
=True =False > < = <>

VBA

IfThen ( )

VBA

If
if-else if-else ifelse

VBA

1. sheet 3
2. 3 5 7
2. sheet range
(by Counta, or CountBlank)
3.
show (ex.
15.8)

VBA

(2)
1. 3

7.

VBA

SelectCase ( )
Case 1 To 10 1,2,3 Is <>8

VBA

SelectCase ( )

VBA

SelectCase ( )

VBA

(Indentation)

VBA

1. 1 12 show
2.

VBA

ForNext ( )

N 1
N 1

VBA

ForNext ( )

VBA

ForNext ( )

VBA

ForNext

VBA

1. Excel Sheet

( : 1 )
Excel Sheet 1-10 7 11 13
17
1. (ex. 15566551)
3% 10%
5%

VBA

1. show 1+1/2+1/3+1/41/n n

2. sheet n(now is 10)

VBA

1. sheet n(now is 10)

8. (ma240)( )

VBA

DoWhile DoUntil
DoWhile DoUntil
ATM

* Do

VBA

On Error

VBA

VBA

1. 3

VBA

For Each ( )
For Each

VBA

For Each ( )

Excel

Excel

WorkBook

Excel

WorkSheet

Excel

Excel

-Worksheet_SelectionChange

Excel

-Workbook_Open

Excel

-Workbook_BeforeClose

Excel

THE END

You might also like