0% found this document useful (0 votes)
8 views8 pages

Macro and Form

Uploaded by

Nwe Nwe Soe
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
0% found this document useful (0 votes)
8 views8 pages

Macro and Form

Uploaded by

Nwe Nwe Soe
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/ 8

University of Computer Studies(Thaton)

CST-1253(SS): Supporting Skills II


(Advanced Microsoft Office 365)

Presented by Dr. Nwe Nwe Soe


Professor
ITSM Dept

1
VBA Code @Excel

• Right click @Ribbon


• Customize ribbon -> Developer then check box click and ok.

1 2
Assign a macro to a Form or a Control button

• You can use a Form control button or a command


button (an ActiveX control) to run a macro that
performs an action when a user clicks it.
• Both these buttons are also known as a push button,
which can be set up to automate the printing of a
worksheet, filtering data, or calculating numbers.
• In general, a Form control button and an ActiveX
control command button are similar in appearance and
function.
• However, they do have a few differences, which are
explained in the following sections.
3
Add a button (Form control)

• On the Developer tab, in the Controls group, click Insert, and then under
Form Controls, click Button Button image .

• Click the worksheet location where you want the upper-left corner of the
button to appear. The Assign Macro popup window appears.

• Assign a macro to the button, and then click OK.

• To specify the control properties of the button, right-click the button, and
then click Format Control.

1 4
Add a command button (ActiveX control)

1. On the Developer tab, in the Controls group, click Insert,


and then under ActiveX Controls, click Command Button
Button image .

2. Click the worksheet location at which you want the


upper-left corner of the command button to appear.

3. In the Controls group, click View Code. This launches the


Visual Basic Editor. Ensure that Click is chose in the
drop-down list on the right. The sub procedure
CommandButton1_Click (see the figure below) runs
these two macros when the button is clicked: Select C15
and HelloMessage.

1 5
Add a command button (ActiveX control)
4.In the subprocedure for the command button, do either of the following:
5.Enter the name of an existing macro in the workbook. You can find macros by clicking Macros in
the Code group. You can run multiple macros from a button by entering the macro names on separate
lines inside the subprocedure.
6.As necessary, add your own VBA code.
7.Close the Visual Basic Editor, and click Design Mode Button image to ensure design mode is off.
8.To run the VBA code that is now part of the button, click the ActiveX command button that you
just created.
9.To edit the ActiveX control, make sure that you are in design mode. On the Developer tab, in the
Controls group, turn on Design Mode.
10. To specify the control properties of the command button, on the Developer tab, in the Controls
group, click Properties Button image . You can also right-click the command button, and then click
Properties. 6
References

• https://www.youtube.com/watch?v=AByFH0TN53M
• https://support.microsoft.com/en-us/office/assign-a-macro-to-a-form-or-a-control-
button-d58edd7d-cb04-4964-bead-9c72c843a283

1 7
Thank you
8

You might also like