MS EXCEL MACROS OR VBA (Virtual Basic Application)
Belajar Excel Macro VBA Untuk Pemula
Tips for Beginners, send to safrish@yahoo.com Email or Phone 0210-84976826 / 081511401617 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 |


Safri Ishak
Yahoo! Messenger

Email SafriSH@Yahoo.com
Phone (021)84976826, HP:081511401617.

Tebet Barat 5 no 12 Jakarta Selatan 12810.
version 05-FEB-2011
2007-2011 www.tb512.com

tebet  orangutan
tebet wwfSahabat Alam Salam Online

The Famous
Indonesian
Folklore

Please Post Your Add - Silahkan Pasang Iklan
Untuk yang berminat silahkan kirim email ke SafriSH@yahoo.com atau SMS ke 081511401617 atau YM! Yahoo! Messenger


e-Order Mulai Masuk 21December2010

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.


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

Tebet Business Directory Alamat Usaha Kita, Free Ads on this page
Free Posting IKLAN GRATIS, send your name, address, telephone, email id, website and brief description of your business to AdminTebetbarat.com

click to enlarge

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 | Main Excel, Topnya Excel Tips | 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


 
EXIT
 
 
 
 
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.