The macro is just a program saved by VBA code.
The basic function of macros is to reduce repetitive operations.
Bring up the macro main tab in Excel20 13.
To use a macro, we must first bring up the command tab of the macro. The operation is as follows:
(1) Select in turn? Documents? ,? Options? ,? Customize the ribbon? ,? Main tab? , as follows:
What if it is not on the right? Develop tools? This project, and then click on the left? Develop tools? And click? Supplement? Yes, then tick and click OK.
If there is one on the right? Develop tools? Ok, then check the box in front of it and click OK.
(2) Will it appear in the label area after completion? Develop tools? Yes As follows:
So we brought macro tags.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Let's use a small example to see how to record a macro.
The payroll is made as follows:
We want to change the table above to the following style:
In fact, this is just a row of cells repeatedly inserted into a blue background. We just use macros to operate.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following are the operation steps:
(1) first select cell A 1, as shown below:
2 in? Develop tools? Choice? Use relative references? , as follows:
(3) click? Recording macros? , as follows:
This means that we give the macro a name and set a shortcut key with some comments.
Then click OK.
(4) This starts recording. Then we select the row corresponding to cell A 1, as shown below:
(5) Then right-click and select Copy, as shown below:
(6) Then select the third line, as shown below:
(7) Right click to select? Insert copied cells? After that, as follows:
(8) Then select cell A3, as shown below:
(9) Click End Record:
See the top? Stop recording? Did you press the button? Just click on it.
In this way, we have finished recording a macro. As you can see, our macro will give the steps of how to insert a line with a blue background.
I remember. Below we can use this macro to replace these tedious steps.
Use of macros
The following uses the macro just recorded to generate a payslip, and the operation steps are as follows:
(1) If we don't choose the A3 cell, we should choose the A3 cell first, as shown below:
(2) click? Develop tools? Under it? Macro? Button, as shown below:
Selected? Generate payroll? , and then click Go. As follows:
We found a new blue background line inserted. Is the way we want it.
(3) Repeat the step (2) continuously. You can make it into a payroll soon.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quick use of macros
What? Do you think it is too much trouble to use macros like the above, and the efficiency is still very low! It doesn't matter, there are three ways to use macros quickly, whatever you want.
Free choice.
=================================
(1) Use shortcut keys
Remember the shortcut keys we set when recording macros? That's ctrl+Q. You just need to select cell A3 and press the shortcut key of CTRL+Q all the time.
Do it. Then the paycheck you want will be generated soon.
=================================
(2) Use button form
What if you don't think the shortcut keys are humanized enough? For example, if you give someone your form, they forget the shortcut keys? it doesn't matter
You can directly make the recorded macro into a button and let it click this button directly. The operation is as follows:
Choose first? Develop tools? Under it? Insert? , select the first one under the form control? Button? . As follows:
Then draw a button in the right place, and you will be asked to choose the specified macro. You chose the song we just recorded? Generate payroll? Just,
As follows:
Click OK, as shown below:
Then let's change the name of the button as follows:
Then click this button repeatedly, and you can generate the payslip style you want.
It should be noted that the last cell in the same position as the A3 cell should be selected at this time, and then you can click this button continuously to generate.
=================================
(3) Put the macro on the ribbon.
What? Not convenient and humanized enough! ! For example, if you keep clicking the button, there are too many rows in the table, and finally you have to pull it up.
You can see the button first and then click it. So why not put the macro in the custom ribbon? The manufacturing steps are as follows:
First, right-click the ribbon and select? Customize the ribbon? , as follows:
So we choose? New tab? , as follows:
Then right-click to rename the tab and rename the new group as follows:
And then we choose on the left? Macro? , and then select? Generate payroll? We just recorded the macro and clicked? Supplement? , add it to the right? Generate payroll? In this group.
As follows:
Click Add as follows:
Then click OK. As follows:
We found an extra label on the ribbon. I recorded a macro? Under this tab, there is a file named. Generate payroll? , in this group.
There is a button on the surface, also called' Generate Payslip? .
Then we can click this button repeatedly to generate the payroll you want. It should be noted that the last one should be selected at this time.
A cell with the same position as the A3 cell, and then you can click this button to generate it.