Add a Simple Button
To see how the Button control is still useful, follow these steps to extend the Stock History sample:
Create a new, blank worksheet.
Click the Toggle Grid button to turn the worksheet gridlines off.
Click the
Buttoncontrol that you added to the Control Toolbox in the previous section and click and drag on the worksheet to draw the button control. Excel displays the Assign Macro dialog box (Figure 20-17).Select StockHistoryDialog2 and click OK.
Type
Get Historyin the button caption and then click the worksheet to deselect the button.Click the Get History button to run the sample.

Figure 20-17. Use the Button control to run a macro
The Button control offers fewer properties than the CommandButton, and they are accessed differently as well. To change the macro assigned to the button, edit its caption, or change any other setting, right-click the button and choose the property to change from the context menu.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access