MS EXCEL MACROS OR VBA (Virtual Basic Application)
Tips for Beginners, send Email or YM! for inquiry and help

 


My First Macro
Copy and paste the following statements to Visual Basic Editor:
Copy dan paste pernyataan berikut ke Visual Basic Editor:
Option Explicit
Sub TEST()
MsgBox "My First Macro"
End Sub

Download My First Macro and Discussion in English and Bahasa Indonesia


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.

 

 

 

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.