Читать книгу Excel Macros For Dummies онлайн
26 страница из 60
The best way to understand how this concept applies to macros is to try it. Open the Chapter 1 Sample File.xlsx file and record a macro that counts the rows in the Branchlist worksheet. (See Figure 1-2.)
ssss1 Your pre-totaled worksheet containing two tables.
Follow these steps to record the macro:
1 Before recording, make sure cell A1 is selected.
2 Select Record Macro from the Developer tab.
3 Name the macro AddTotal.
4 Choose This Workbook for the save location.
5 Click OK to start recording.At this point, Excel is recording your actions. While Excel is recording, perform the following steps:Select cell A16 and type Total in the cell.Select the first empty cell in Column D (D16) and enter = COUNTA(D2:D15).This gives a count of branch numbers at the bottom of column D. You need to use the COUNTA function because the branch numbers are stored as text.
6 Click Stop Recording on the Developer tab to stop recording the macro.
The formatted worksheet should look something like the one in Figure 1-3.