Home>Article>Topics> How to make a small program in excel?

How to make a small program in excel?

coldplay.xixi
coldplay.xixi Original
2020-07-22 11:11:41 35594browse

How to make a small program in excel: first open the VBE interface and click [User Form]; then create a command button and change the display content of the command button; then double-click the user form and replace the original code; Finally save the file and enable it.

How to make a small program in excel?

How to use a small program in excel:

1. Press Alt F11 in Excel to open the VBE interface , as shown in the figure below:

How to make a small program in excel?

2. Click "Insert", "UserForm", as shown in the figure below:

How to make a small program in excel?

3. Then click "Command Button" and drag on the user form to create a command button, as shown below:

How to make a small program in excel?

4. Press Press F4, and in the Caption property, change the display content of the command button, as shown below:

How to make a small program in excel?

5. Then double-click the user form and replace the original code with the following code

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) If X > 0 Then Me.Left = Application.RandBetween(0, 800) Me.Top = Application.RandBetween(0, 350) End If End Sub

As shown in the figure below:

How to make a small program in excel?

6. Double-click "Thisworkbook" on the right and copy the following code, as shown in the figure below:

Private Sub Workbook_Open() UserForm1.Show End Sub

How to make a small program in excel?

7. Save the Excel file as "Excel macro-enabled workbook", as shown below:

How to make a small program in excel?

8. Close and then open the Excel file, you can see the written program, as shown below:

How to make a small program in excel?

Related learning recommendations:excel basic tutorial

The above is the detailed content of How to make a small program in excel?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn