Linking a button to a macro

To run a macro from the macro dialog box, the user must be aware that the macro exists, and several keystrokes are required to invoke it! As an alternative, you can linked a macro to a button - that can be placed anywhere on a sheet. Users can then invoke a macro by simply clicking the button.

To link a button to the updateSalesRep macro:

1 Select the weeklysales worksheet from the SALESMAN workbook.

2 Select View > Toolbars > Forms to display the Forms toolbar on the worksheet. Make sure the worksheet is unprotected, otherwise the Forms toolbar will be greyed out.

3 Click the Button icon on the Forms toolbar, then click on the worksheet where you will want this to appear. You will then see the Assign Macro dialog box. To assign an existing macro to the button or graphic control, enter the name of the macro in the Macro name: field, and click OK.

E3 Microsoft Excel - SALESMAN

x.:

■IfP] File Edit View .Insert Format Tools Data Window Help Type a c

□ e? y S) " Ariai -in - b z u ® » * ip ® %

luestion hj

rhelp fl p & - A .

X »

J48 -

An.

A

B

c

D

E

F

I $

1

.27

□ -i

28

Bonus Rile:

a

17 9

29

Month No:

¡1

lies

30

Weekly S;

a a

31

Rtp Name

Sales To Date

1

2

3

4

Monthly Total

Month!

End ofMonth S;

Hindi

Katie

Misba

Pete

Rhiannon Gareth

13 J

54

■5

6

12

77

£

s H

33

459

32

43

28

33

136

£

»#

34

357

16

33

150

166

M

t1

35

540

32

77

:52

19

180

£

tf" B

1

36

489

44

54

0

53

157

£

SB

37

333

20

56

39

78

193

£

1 *

36

336

i?

100

9

-7

123

■£. 615.00

39

433

33-

54

402

68

557'

£ .'2-.7-8.i-.00

40

330

77

44

:33

18

122

£ 610.00

41

Itotals

3432

279

466

719

446

1910

9559

42

43

44

45

■ updateSalesRep

46

47

46

its

{ week sales test data ,

( Sheet 1 / 5heet3 /Hi * 1

Ready

A

Figure 2.7 The button updateSalesRep on the weeklysales worksheet.

Figure 2.7 The button updateSalesRep on the weeklysales worksheet.

Figure 2.8 The Assign Macro dialog box

4 Resize and name the button. Move the cursor to some other point on the worksheet and click to deselect the button. Its appearance will be similar to that in Figure 2.7. The button can now be used to run the macro.

0 0

Post a comment