100% found this document useful (1 vote)
72 views

Excel Macro/VBA: Alfi Magfirwan

This document provides an overview of Excel macros and VBA (Visual Basic for Applications). It covers topics such as the VBA environment, modules, security, recording macros, variables, control statements, events, userforms, interacting with other applications, and error handling. Examples are provided for common tasks like conditional logic, loops, validating user input, email automation, and file manipulation. The goal is to introduce core VBA concepts and capabilities through explanations and hands-on exercises.

Uploaded by

Alfi Ramadhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
72 views

Excel Macro/VBA: Alfi Magfirwan

This document provides an overview of Excel macros and VBA (Visual Basic for Applications). It covers topics such as the VBA environment, modules, security, recording macros, variables, control statements, events, userforms, interacting with other applications, and error handling. Examples are provided for common tasks like conditional logic, loops, validating user input, email automation, and file manipulation. The goal is to introduce core VBA concepts and capabilities through explanations and hands-on exercises.

Uploaded by

Alfi Ramadhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

Excel Macro/VBA

Alfi Magfirwan
Course Detail
Introduction

Alfi Magfirwan Ramadhan


VBA Scope and Capability
 VBA Scope
Only for Microsoft Office Products (Need Host)
VBA Capability
 Easy to Learn (Human being languange)
 Support Automation (Capable to Interact with another
application)
 Custom Interface (Capable to change excel environment)

Easy Custom Interface


OLE Automation
VBE Environment;Component

VBA Module VBA project tree


VBE Environment;Module
Macro Security
Macro Record

Limitation
Macro Record;Transform Action into Code
Programming Basic

Alfi Magfirwan Ramadhan


OOP (Object Oriented Programming
OOP:Properties and Method

Method
Object

Properties
Event
OOP:Properties
Properties

Setting

Part of the Object


OOP:Method

Method
Argument

Used Named
Comma Argument
OOP (Object Oriented Programming
Things to Remember Learn About Objects
Variable Declaration
Long
String
Type
Declare Variable
Integer
Etc
Public
Scope Private
Dim
Variable Scope
Variable Type
Control Statement

Alfi Magfirwan Ramadhan


If then else Statement
For each next Statement
Exercise
 If then Else
Buat program yang bisa memberitahu waktu, apakah ini pagi,
siang atau malam
 For Each Next
Buat program untuk mensave semua workbook yang aktif
Buat program untuk memproteksi dan unproteksi semua
worksheet dalam satu workbook.

Buat program untuk memproteksi dan unproteksi semua


worksheet dalam semua workbook.
Event

Alfi Magfirwan Ramadhan


Event in Excel
Workbook

Application Event Worksheet

Userform
Workbook Event
Worksheet Event
Exercise
 Memberi Informasi pada inputan data
Buat program untuk memberitahu user suatu informasi pada
saat saya klick cell tertentu.

 Memberi mark pada inputan data


Buat program untuk membold karakter tertentu di cell
Buat program untuk memberi warna (vertical dan horizontal)
dari aktif cell yang diketik
Userform

Alfi Magfirwan Ramadhan


Msgbox Function

Inputbox Function
Creating Userform
Exercise

 Buat Msgbox yang menjalankan perintah tertentu


 Membuat Spalsh Screen
Interact With Another Application
(OLE)

Alfi Magfirwan
Early binding vs Late binding
Exercise
 Email
Buat program untuk membuka email dan atau menulis sesuatu
pada body email
Buat program untuk membuka email sekaligus memberikan
attachment pada outlook

 File Manipulation
Buat program untuk mengcopy file dari satu direktori ke
direktori lain
Error Handling

Alfi Magfirwan Ramadhan


Error Handling
Exercise
 Buat msgbox yang muncul saat program anda error
Thank You

Alfi Magfirwan Ramadhan

You might also like