Professional Documents
Culture Documents
2.
Choose Popular and activate Show Developer tab in the Ribbon. Click OK.
[1 ]
Note: Workbook standard Excel 97-2003 using XLS format file support Macro feature, while for Excel 2007 using XLSX format
file do not support Macro feature. However, it can be utilized using the format file XLSM and XLSB.
If you have managed the data in the file that you had activated with VB, then you are able to go for next process of
using Visual Basic. Instead, go to Control and Manage the Trust Center
[2 ]
EXCEL 2010
1 .Click File Option Customize Ribbon Developer OK.
[3 ]
2 .Click Developer will show Visual Basic and Macros on the left Menu.
[4 ]
[5 ]
2. Click Trusted Location [where you can save your data]. While you want to add the new location for your data,
then you have click Add New Locations as figure below.
[6 ]
3. After you decide to which you will be to save the data (as figure above), then you chose ActiveX Setting
Enable all controls (as figure below) OK.
[7 ]
4. After you click OK, then chose Macro Setting Enable all controls and Trust access to the VBA to activate
Visual Basic project (as figure below) OK.
5. In order to de-active the warning default, chose Message Bar Never show informationand Enable Trust
Center logging (as figure below) OK.
Finish.
[8 ]
To run visual basic editor Excel 2003, Tools Macro Visual Basic Editor.
While for Excel 2007 is choose Developer Visual Basic or directly press together Alt+F11. It will appear the window
of VB as below:
If the window of VB appears without Properties as figure below, you can click on Properties to show the properties of VB.
2.
[9 ]
3.
4.
While for Code, click on View table Code so that appear the box for coding activity as figure in the right side.
5.
OBJECT SELECTOR
EVENT SELECTOR
[10 ]
6.
When to typing the code to macro, we can utilize Autolist feature to show the list, collection, properties or method used
of Object as below.
7.
After click Record Macro, it will appear the box of Record Macro with
Macro name is Macro1.
Change the macro name to LATIHAN
[11 ]
Type in
o sel A1 is HASOLOAN HAERY
o sel A2 is LECTURER FOR DITG 3113
[12 ]
Stop Recording
a. To run Macro with recording the steps, we also can do directly by as follows:
o
o
o
Open Excel
ALT + F8
After Macro box open, type the Macro Name (Latihan) and the press Create so that appear Module 1(Code
box).
[13 ]
o
o
o
o
o
o
o
8.
To save the Macro file, generally Microsoft Excel will save the file with *.XLS (or *.XLSX for Excel 2010). However, to
save the excel files with Macro content, the file should be saved with *.XLSM (Excel Macro Enabled Workbook).
[14 ]
EXAMPLE :
1.
a.
b.
[15 ]
c.
d.
e.
Type in the Module Box : "Hallo Apakabar....Apakah anda sudah boleh membuat MACRO VBA?"
[16 ]
f.
g.
Everytime you open the Macros in Excel, it will appear as figure below.
h.
When you type "Hallo" Run, you will see the Box as picture below.
i.
If you press OK, this is meant you are working in Macros environment.
j.
Finish
[17 ]
2.
b. To make the new form, double click on ThisWorkbook to appear the Box.
[18 ]
[19 ]
d. To generate the form object, you can use the Control Toolbox.
Chose Label []
Chose Label []and ] drag to the UseForm and type "CALCULATE" as picture below.
[20 ]
e. Manage the TextBox: active on Length Blank Box and Type "TextBoxLENGHT" .
f.
Be ensured the Enabled is "TRUE". Do the same way for 'WIDTH", while for "Calculation for AREA" the
Enabled is "FALSE".
For "CALCULATE", change the CAPTION to: CALCULATE.
[21 ]
g. Run the program by pressing F5 or RUN menu to show the filling form as below.
h. After the UserForm appear, then type the number on blank column. e.g. LENGTH = 10 ; WIDTH = 20 and then press
CALCULATE. The result shows in the Calculation for AREA (=200).
*** HOW YOUR RESULT? [DO YOU FIND YOUR PROGRAM IS FALSE???, IF YES, WHY? DISCUSS!!!]
[22 ]
Answer:
* You can revise your program as below:
OR
The reason is due to Calculate is a command; not as manipulation of what you want from the process.
c. By double clicking on "UseForm1" and changing the TextBoxCalculationfor AREA to become "FALSE" and then
execute the program by double clicking the CALCULATE box and then pressing F5 or Run the program, what the
result? Can you type the data inside the blank and get the result needed?
[23 ]
3.
[24 ]
b. Click Visual Basic tools on the Developer menu and then right click to show Insert User Form.
c. After show the working environment, it is required to manage the properties form as below.
[25 ]
(Name) : BOOKRENT
Caption: BOOK BORROEWER
Enabled: True
Drag
Drag
Repeat this step for "ADDRESS" and "PHONE", while for "BOOK" use
(ComboBox); "NEW" and "OLD" use
(CheckBox) and "YES" or "NO" use
(Option Button).
In Figure below, for "NEW" and "OLD" or "YES" or "NO" are circled with Frame
For OK button using Command Button.
o
o
[26 ]
f.
Type the complete command as below and RUN the program by pressing F5 or RUN menu.
[27 ]
g. Fill and tick the Blank in Box and pressing OK to end the cycle so that in the excel shows as below.
[28 ]
4.
c. Click Visual Basic tools on the Developer menu and then right click to show Insert User Form.
d. Follow the process 3d until 3e. However, the LOCATION is 'ComboBox, while TOTAL Prices is Quantity x Price.
e.g. LOCATION are: Makmal Bahan, Makmal Proses, Makmal Rekabentuk, Makmal Robotik and Makmal Pengurusan.
[29 ]
f.
[30 ]
i.
Fill up the data on database by writing on the Material Data Box and do repeatedly based on the data you have.
FINISH
[31 ]