MS EXCEL MACROS OR VBA (Visual Basic Application)
Excel Macro VBA Programming and Developer Jakarta
Tips for Beginners, send to safrish@yahoo.com Email or Phone 081511401617 or WA 08158812522 or YM! Yahoo! Messenger for inquiry and help
Belajar Excel Macro (Google) | Mr Excel | Main Excel, Topnya Excel Tips | XLMania Yahoo Group | VBA Expert | Excel itu Mudah (Kontributor Ardo Ronald) | Silabus |
Download the Complete Tutorial on Excel Macro
|
XL-Mania Mengapa Boss Benci Chart Anda | Klinik Excel Solusi Masalah Excel Kita |
Excel Guru |

Safri Ishak
EmailSafriSH@Yahoo.com


Email SafriSH@Yahoo.com
Phone 081511401617.

Tebet Barat 5 no 12 Jakarta Selatan 12810.
version
08-NOV-2020
© 2007-2019 www.tb512.com
Check Google Page Rank

tebet  orangutan
tebet wwf
Sahabat Alam
Salam
Online

The Famous
Indonesian
Folklore

 

Excel Macro VBA – Visual Basic for Application.

Mengenal Visual Basic for Application

Sejarah dan defenisi

Visual Basic for Applications (VBA) adalah implementasi dari bahasa pemrograman yang dijalankan oleh Microsoft, Visual Basic 6, yang dihentikan pada tahun 2008, dan lingkungan pengembangan terintegrasi atau integrated development environment (IDE) yang terkait. Meskipun Visual Basic tidak lagi didukung atau diperbarui oleh Microsoft, bahasa pemrograman VBA ditingkatkan pada tahun 2010 dengan diperkenalkannya Visual Basic for Applications 7 dalam aplikasi Microsoft Office.

Visual Basic for Applications memungkinkan membangun fungsi yang ditentukan pengguna atau user-defined functions (UDF), mengotomatisasi proses dan mengakses Windows API dan fungsionalitas tingkat rendah lainnya melalui dynamic-link libraries (DLLs). Ini menggantikan dan memperluas kemampuan bahasa pemrograman makro spesifik aplikasi sebelumnya seperti WordBASIC Word. Hal ini dapat digunakan untuk mengontrol banyak aspek dari aplikasi host, termasuk memanipulasi fitur antarmuka pengguna, seperti menu dan toolbar, dan bekerja dengan formulir pengguna kustom atau kotak dialog.

 

Seperti namanya, VBA terkait erat dengan Visual Basic dan menggunakan Visual Basic Runtime Library. Namun, kode VBA biasanya hanya dapat berjalan dalam aplikasi host, bukan sebagai program mandiri. VBA dapat, bagaimanapun, mengontrol satu aplikasi dari yang lain menggunakan OLE Automation. Misalnya, VBA dapat secara otomatis membuat laporan Microsoft Word dari data Microsoft Excel yang dikumpulkan secara otomatis dari sensor yang disurvei.

VBA dapat menggunakan, tetapi tidak membuat, ActiveX / COM DLL, dan versi yang lebih baru menambahkan dukungan untuk modul kelas. VBA dibangun ke sebagian besar aplikasi Microsoft Office, termasuk Office untuk Mac OS X (kecuali versi 2008), dan aplikasi Microsoft lainnya, termasuk Microsoft MapPoint dan Microsoft Visio. VBA juga diimplementasikan, setidaknya sebagian, dalam aplikasi yang diterbitkan oleh perusahaan selain Microsoft, termasuk ArcGIS, AutoCAD, CorelDraw, LibreOffice, Reflection, SolidWorks, dan WordPerfect.

Fungsi VBA

VBA digunakan Microsoft Excel untuk membuat alat canggih yang dapat digunakan dalam bisnis, teknik, dan sains. VBA memungkinkan pengguna mengkostumisasi dengan level melebihi dari apa yang biasanya tersedia di produk Microsoft Office, seperti Excel, Word dan Power Point. Seorang pengguna mengetik perintah ke dalam modul pengeditan untuk membuat macro. Macro kemudian memungkinkan pengguna untuk secara otomatis membuat laporan, bagan dan melakukan fungsi pemrosesan data lainnya. Dalam industri keuangan, VBA untuk Excel biasanya digunakan untuk mengembangkan dan memelihara model spreadsheet keuangan yang kompleks.

Desain cepat dan alat analisis untuk rekayasa dapat dengan mudah dibangun di aplikasi kantor yang menggunakan VBA. VBA adalah alat serba guna yang hebat untuk menyesuaikan pengalaman Office Anda. Bahasa VBA cukup mudah dipelajari, dan memiliki kekuatan yang baik. Meskipun Excel VBA tidak umum digunakan di beberapa industri, ia sangat populer di sektor keuangan seperti perbankan investasi, dll. (referensi: wikipedia, softwaretogo.de etc)


Please subscribe to our Channel
Please visit our Business Site


Belajar Excel Macro
Step by Step

1. Intro
2. Development Menu
3. My First Macro
4. Dashboard
5. Blast Email
6. Dashboard Procurement


Download

1. My First Macro
2. Converting Text File to Excel
3. Converting Date to Text
4.
Total Amount Based On Cost Code Group
5. Exracting Last Name without space
6. Combining Several Sheets


Diskusi

1. My First Macro
2.
Converting Text File to Excel
3. Converting Date to Text
4. Total Amount Based On Cost Code Group

5. Exracting Last Name without space
6. Combining Several Sheets



 
 

Belajar Excel Macro
Step by Step

1. Intro
2. Development Menu
3. My First Macro
4. Dashboard
5. Blast Email
6. Dashboard Procurement
7. Folder Sync
8. Menu Masakan

please subscribe

 
business

Download

1. My First Macro
2. Converting Text File to Excel
3. Converting Date to Text
4.
Total Amount Based On Cost Code Group
5. Exracting Last Name without space
6. Combining Several Sheets


 

Diskusi

1. My First Macro
2.
Converting Text File to Excel
3. Converting Date to Text
4. Total Amount Based On Cost Code Group

5. Exracting Last Name without space
6. Combining Several Sheets



 

 

click to enlarge

EXCEL VERSI LAMA

Enable Macro to run in Excel Workbook
Open Excel, click Tools, click Macro, click Security, select Medium and click OK. Close Excel.
Note: we need to do it only once.
Buka Excel, klik Tools, klik Macro, pilih Medium dan klik OK. Tutup Excel.
Catatan: mengaktifkan macro cukup dilakukan sekali saja.

 
Edit Macro
Open Excel, On Excel worksheet, click Tools, click Macro, click Visual Basic Editor.
On Visual Basic Editor, click Insert, click Module.

My First Macro
Copy and paste the following statements to Visual Basic Editor:
Option Explicit
Sub TEST()
MsgBox "My First Macro"
End Sub
Download My First Macro and Discussion in English and Bahasa Indonesia


Belajar Excel Macro (Google) | Mr Excel | XLMania Yahoo Group | VBA Expert | Excel itu Mudah (Ardo Ronald) |


Converting Text File to Excel (22-September-2010)
Read data from text file and create Summary data in Excel format.
Download Text2ExcelSample.zip (18 KB) and Discussion

Converting Number to Text (Indonesian Module by Eka Priatna)
234 = dua ratus tiga puluh empat
Discussion

Converting Date to Text (Case Study XL_Mania@Yahoogroups.com)
10/03/2008 = tanggal tiga bulan oktober tahun dua ribu delapan
Download Sebutan Tanggal (20 KB) and Discussion

Total Amount Based On Cost Code Group (Case Study XL_Mania@Yahoogroups.com)
Download Cost Code Total (45 KB) and Discussion

Exracting Last Name without space (Case Study XL_Mania@Yahoogroups.com)
MansurIshak = Ishak
Download Last Name Version 1.0 (25 KB) Discussion
Download
Last Name Version 1.1 (45 KB) Modification Version based on Siti's feedback Discussion

Combining Several Sheets (Case Study XL_Mania@Yahoogroups.com)
Download Combine Sheets (36 KB) Discussion


e-Order Mulai Masuk

Alhamdulillah berkat doa dan bantuan kawan kawan yang saya kenal lewat internet, sudah ada beberapa order yang masuk untuk men-develop excel VBA (Excel Macro). Umumnya untuk membuat Ad-hoc Reports & Charts yang inputnya di download dari Corporate Database dalam bentuk excel format, Ad-hoc reports dibutuhkan untuk menunjang decision maker dalam membuat keputusan.

Kemudian ada permintaan untuk membuat reports yang agak rumit kalau hanya menggunakan formula yang ada di excel dengan jumlah data yang banyak akan menyebabkan file size jadi besar dan calculation time jadi lama.


Ada juga order untuk membuat input data dengan menggunakan user form kemudian input data tersebut di upload ke untuk meng-update database.


Extract Data dan Automatic Outlook Email Send

Data yang di-extract dengan kriteria tertentu kemudian dikirim melalui Outlook.
Selain data yang dikumpulkan dalam satu file ada juga beberapa file yang di-zip terlebih dahulu sebelum dikirim,


Konversi Operational Data ke Standard Format

Data yang di-download dari Operational Database (dari SAP ke Excel) dikonversi ke format yang telah ditentukan untuk keperluan pelaporan diantaranya Vendor & Customer, Stock Take Document, Pabean Document, Goods Document, Bill of Material dan Production Document.


Sistim Pemantauan Data Piutang

Membuat beberapa Laporan Pemantauan Data Piutang diantaranya Covenant Due Report, Paymen Due Report, Excess Report dan lain lain dengan menggabungkan beberapa Excel files.

User form untuk mengupdate Completion Date dan Piutang Database.


e-Buah iklan lewat internet 15JUL2009
Tebet Business Directory
Akhir bulan Juni 2009 ada sahabat maya yang menghubungi saya lewat YM! dan bertanya apakah saya seorang Excel Macro Professional, karena beliau akan membuat sebuah project yang harus menggunakan Excel Macro, alamat saya ditemukannya lewat searching google
dengan keyword "belajar excel macro" yang link ke tb512.com.

Agak susah juga saya menjawabnya karena standard apa yang harus digunakan, kalau pengalaman mengunakan Excel Macro, saya sudah menggunakannya sejak tahun 1995, kalau pengalaman memberikan training Excel Macro, sudah lebih dari 20 kelas, kalau ukurannya jumlah Excel Macro yang telah dibuat, sudah lebih dari 500.

Akhirnya kami setuju kopi darat dan bertemu di rumah saya. Mula mula kami sepakat untuk bekerjasama menyelesaikan project tersebut, tetapi setelah menyelesaikan beberapa module, akhirnya Project Manager memutuskan agar saya memberikan Excel Macro Training saja selama 15 jam dengan training fee US$ 30.00 per jam.

Alhamdulillah ada hasilnya juga membuat blog Belajar Excel Macro Untuk Pemula, dapat banyak teman konsultasi atau minta tolong lewat YM! dan dapat rezeki walaupun relative tidak banyak, tetapi kalau dibandingkan dengan tarif pemasangan banner sebesar 50 ribu rupiah per tahun lumayan juga lah :) tb512.com

 

 

 

EXIT

 

Feedjit Live Website Statistics

 

Tebet Business Directory Alamat Usaha Kita
Free Posting IKLAN GRATIS, send your name, address, telephone, email id, website and brief description of your business to AdminTebetbarat.com
More information about www.TB512.com Click HERE.

 

My First Macro

Exctracted from Excel Macro Help.

Option Explicit Statement
Used at module level to force explicit declaration of all variables in that module.
Syntax
Option Explicit

Remarks
If used, the Option Explicit statement must appear in a module before any procedures.
When Option Explicit appears in a module, you must explicitly declare all variables using the Dim, Private, Public, ReDim, or Static statements. If you attempt to use an undeclared variable name, an error occurs at compile time.
If you don't use the Option Explicit statement, all undeclared variables are of Variant type unless the default type is otherwise specified with a Deftype statement.
Note Use Option Explicit to avoid incorrectly typing the name of an existing variable or to avoid confusion in code where the scope of the variable is not clear.

Option Explicit Statement
Dengan menggunakan option ini, maka semua variable (akan kita diskusikan lebih lanjut) harus di deklarasikan.
Option Explicit harus dibuat dan diletakkan paling atas, sebelum prosedur yang lain. Untuk menghindari kesalahan meng-edit pada waktu menggunakan variable, sangat dianjurkan untuk memakai Option Explicit.


Sub TEST() Statement
Declares the name, arguments, and code that form the body of a Sub procedure.
Syntax

[Private | Public | Friend] [Static] Sub name [(arglist)]
[statements]
[Exit Sub]
[statements]

End Sub

Sub TEST() Statement
Digunakan untuk mendeklarasikan nama prosedur, argumen dan perintah yang akan membentuk sebuah Sub prosedur. Semua prosedur didalam Excel Macro dimulai dengan Sub statement dan diakhiri dengan End Sub. Dalam contoh ini nama yang digunakan adalah TEST.

MsgBox Statement
Displays a message in a dialog box, waits for the user to click a button, and returns an Integer indicating which button the user clicked.
Syntax
MsgBox(prompt[, buttons] [, title] [, helpfile, context])

The MsgBox function syntax has these named arguments:
prompt Required. String expression displayed as the message in the dialog box. The maximum length of prompt is approximately 1024 characters, depending on the width of the characters used. If prompt consists of more than one line, you can separate the lines using a carriage return character (Chr(13)), a linefeed character (Chr(10)), or carriage return – linefeed character combination (Chr(13) & Chr(10)) between each line.
buttons Optional. Numeric expression that is the sum of values specifying the number and type of buttons to display, the icon style to use, the identity of the default button, and the modality of the message box. If omitted, the default value for buttons is 0.
title Optional. String expression displayed in the title bar of the dialog box. If you omit title, the application name is placed in the title bar.
helpfile Optional. String expression that identifies the Help file to use to provide context-sensitive Help for the dialog box. If helpfile is provided, context must also be provided.
context Optional. Numeric expression that is the Help context number assigned to the appropriate Help topic by the Help author. If context is provided, helpfile must also be provided.

MsgBox "My First Macro" Statement
Digunakan untuk menampilkan kata-kata My First Macro di layar monitor.

Untuk mencoba macro ini, silahkan tekan F5 dari Macro Editor, click RUN, untuk mengakhiri macro click OK.

Click icon untuk melihat gambar dengan ukuran yang lebih besar.

 


Exctracted from Excel Macro Help.

Option Explicit Statement
Used at module level to force explicit declaration of all variables in that module.
Syntax
Option Explicit

Remarks
If used, the Option Explicit statement must appear in a module before any procedures.
When Option Explicit appears in a module, you must explicitly declare all variables using the Dim, Private, Public, ReDim, or Static statements. If you attempt to use an undeclared variable name, an error occurs at compile time.
If you don't use the Option Explicit statement, all undeclared variables are of Variant type unless the default type is otherwise specified with a Deftype statement.
Note Use Option Explicit to avoid incorrectly typing the name of an existing variable or to avoid confusion in code where the scope of the variable is not clear.

Option Explicit Statement
Dengan menggunakan option ini, maka semua variable (akan kita diskusikan lebih lanjut) harus di deklarasikan.
Option Explicit harus dibuat dan diletakkan paling atas, sebelum prosedur yang lain. Untuk menghindari kesalahan meng-edit pada waktu menggunakan variable, sangat dianjurkan untuk memakai Option Explicit.

Dim Statement
Declares variables and allocates storage space.
Syntax
Dim [WithEvents] varname[([subscripts])] [As [New] type] [, [WithEvents] varname[([subscripts])] [As [New] type]]
. . .The Dim statement syntax has these parts:

Part Description
WithEvents Optional. Keyword that specifies that varname is an object variable used to respond to events triggered by an ActiveX object. WithEvents is valid only in class modules. You can declare as many individual variables as you like using WithEvents, but you can't create arrays with WithEvents. You can't use New with WithEvents.
varname Required. Name of the variable; follows standard variable naming conventions.
subscripts Optional. Dimensions of an array variable; up to 60 multiple dimensions may be declared. The subscripts argument uses the following syntax:
[lower To] upper [, [lower To] upper] . . .

When not explicitly stated in lower, the lower bound of an array is controlled by the Option Base statement. The lower bound is zero if no Option Base statement is present.

New Optional. Keyword that enables implicit creation of an object. If you use New when declaring the object variable, a new instance of the object is created on first reference to it, so you don't have to use the Set statement to assign the object reference. The New keyword can't be used to declare variables of any intrinsic data type, can't be used to declare instances of dependent objects, and can’t be used with WithEvents.
type Optional. Data type of the variable; may be Byte, Boolean, Integer, Long, Currency, Single, Double, Decimal (not currently supported), Date, String (for variable-length strings), String * length (for fixed-length strings), Object, Variant, a user-defined type, or an object type. Use a separate As type clause for each variable you declare.

Remarks

Variables declared with Dim at the module level are available to all procedures within the module. At the procedure level, variables are available only within the procedure.

Use the Dim statement at module or procedure level to declare the data type of a variable. For example, the following statement declares a variable as an Integer.

Dim NumberOfEmployees As Integer

Also use a Dim statement to declare the object type of a variable. The following declares a variable for a new instance of a worksheet.

Dim X As New Worksheet

If the New keyword is not used when declaring an object variable, the variable that refers to the object must be assigned an existing object using the Set statement before it can be used. Until it is assigned an object, the declared object variable has the special value Nothing, which indicates that it doesn't refer to any particular instance of an object.

You can also use the Dim statement with empty parentheses to declare a dynamic array. After declaring a dynamic array, use the ReDim statement within a procedure to define the number of dimensions and elements in the array. If you try to redeclare a dimension for an array variable whose size was explicitly specified in a Private, Public, or Dim statement, an error occurs.

If you don't specify a data type or object type, and there is no Deftype statement in the module, the variable is Variant by default.

When variables are initialized, a numeric variable is initialized to 0, a variable-length string is initialized to a zero-length string (""), and a fixed-length string is filled with zeros. Variant variables are initialized to Empty. Each element of a user-defined type variable is initialized as if it were a separate variable.

Note When you use the Dim statement in a procedure, you generally put the Dim statement at the beginning of the procedure.


Sub TEST() Statement
Declares the name, arguments, and code that form the body of a Sub procedure.
Syntax

[Private | Public | Friend] [Static] Sub name [(arglist)]
[statements]
[Exit Sub]
[statements]

End Sub

Sub TEST() Statement
Digunakan untuk mendeklarasikan nama prosedur, argumen dan perintah yang akan membentuk sebuah Sub prosedur. Semua prosedur didalam Excel Macro dimulai dengan Sub statement dan diakhiri dengan End Sub. Dalam contoh ini nama yang digunakan adalah TEST.

LTrim, RTrim, and Trim Functions
Returns a Variant (String) containing a copy of a specified string without leading spaces (LTrim), trailing spaces (RTrim), or both leading and trailing spaces (Trim).
Syntax
LTrim(string)
RTrim(string)
Trim(string)


The required string argument is any valid string expression. If string contains Null, Null is returned.

Replace Function
Description
Returns a string in which a specified substring has been replaced with another substring a specified number of times.
Syntax
Replace(expression, find, replace[, start[, count[, compare]]])

The Replace function syntax has these named arguments:

Part Description
expression Required. String expression containing substring to replace.
find Required. Substring being searched for.
replace Required. Replacement substring.
start Optional. Position within expression where substring search is to begin. If omitted, 1 is assumed.
count Optional. Number of substring substitutions to perform. If omitted, the default value is –1, which means make all possible substitutions.
compare Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values.

Settings

The compare argument can have the following values:

Constant Value Description
vbUseCompareOption –1 Performs a comparison using the setting of the Option Compare statement.
vbBinaryCompare 0 Performs a binary comparison.
vbTextCompare 1 Performs a textual comparison.
vbDatabaseCompare 2 Microsoft Access only. Performs a comparison based on information in your database.

Return Values

Replace returns the following values:

If Replace returns
expression is zero-length Zero-length string ("")
expression is Null An error.
find is zero-length Copy of expression.
replace is zero-length Copy of expression with all occurences of find removed.
start > Len(expression) Zero-length string.
count is 0 Copy of expression.