Professional Documents
Culture Documents
Excel Macro: Aplikom@teknik - Informatika - Unsrat 2010
Excel Macro: Aplikom@teknik - Informatika - Unsrat 2010
Excel Macro: Aplikom@teknik - Informatika - Unsrat 2010
EXCEL MACRO
What’s A Programming
Language?
A system of statements you use to
manipulate a computer
What’s required?
Accept input
Store data
Manipulate data
Produce output
Introducing The Excel Object Model
Methods
Calculate
CheckSpelling
Quit
Events
SheetCalculate
NewWorkbook
WorkbookBeforeClose
Workbook Object
Properties PrintOut
Name Save
Sheets Events
Saved BeforeClose
Methods NewSheet
Close BeforeSave
Worksheet Object
Properties Delete
Name Events
UsedRange Activate
Visible Deactivate
Methods Change
Activate
Copy
Project Properties
Insert-Module
Subroutine HelloMessage :
Sub HelloMessage()
MsgBox ("Hello, world")
End Sub
View-Macro-Run
Subroutine GoodbyeWorld:
Sub GoodbyeWorld()
MsgBox ("Goodbye, world")
End Sub
F5
Modules (2)
Property Windows F4
Label module
Label sheet
Export – Import Module
*.bas
*.txt
etc
Subroutine / Function
D:\~sap\mk- apli komp2\excel vba in depth\Exercise Files\Ex_Files_Excel_VBA\
Ex_Files_Excel_VBA\Exercise Files\Ch01\Commission.xlsm
Subroutine TwoTrees:
Sub TwoTrees()
MsgBox ("Welcome to two trees monthly reporting workbook")
End Sub
F5
Function Broker:
Function Broker(curTotal As Currency)
Broker = curTotal * 0.15
End Function
Alt F11 – Commision – Fx Broker
Subroutine / Function (2)
Function SalesTax:
Function SalesTax(curSales As Currency, dblRate As
Double) As Double
SalesTax = curSales * dblRate
End Function
Alt F11 – SalesTax- Fx SalesTax