Excel Macro: Aplikom@teknik - Informatika - Unsrat 2010

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 13

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

 It’s absolutely huge


 You can buy it in a book, but it’s better to look
at it within Excel
 Let’s hit high points
Application Object

 The top level for an instance of Excel


 Properties
 Version
 Caption
 Default file path
 Workbooks collection
Application Object (2)

 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

 Open VBA alt-F11


 Tools-VBA project properties
 General
 Protection
Modules

 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

You might also like