How do i add macro in excel to button

Liked this question? Tell your friends about it

2 Answers

Order by
Oldest to Newest
Newest to Oldest
Votes

Here's how you do it in Excel 2003:

1. record the marco.

2. right-click anywhere on a toolbar, and choose "costomize" (the last option).

3. on the top, click the "Commands" tab.

4. On the "Catrgories" list on the left, select "Macros" (third from the bottom).

5. On the right side, "Costom Botton" will appear -- drag it to the place you want it to be on the toolbar.

6. One it's on the toolbar, right-click this new button and select "Assign Macro" (the last option).

7. Choose the macro you recorded in stage 1.

I assume you want to add a button to the grid (cell) and process an existing macro when you click the button (and you use Office version different from "Office 2007"). Moreover the existing macro looks like this:

Private Sub Hello_World()
  MsgBox "Hello World"
End Sub

---------------

Steps:

1) Right-mouse click on the toolbar area -> list of toolbars opens -> check "Control Toolbox" (On the top, a toogle button is displayed to switch design mode on/off). 

2) Press the "Command Button" icon

3) Add a button to the area/cell of the grid

4) Doubleclick the button

-> Visual basic displays:

Private Sub CommandButton1_Click()

End Sub

5) Add your existing macro to the sub "CommandButton1_Click"

Private Sub CommandButton1_Click()
  Hello_World
End Sub

6) Switch Design mode off

7) Press button -> Pop-Up is displayed with conteent "Hello World"

I have a great idea -Changing the world ..., what to do? See Tim Berners-Lee's (founder of www) <a href="http://www.w3.org/People/Berners-Lee/FAQ#have" rel="nofollow">FAQ section</a> .

Related Questions

Other people asked questions on similar topics, check out the answers they received:

Asked: Embedding Macro in and Excel Workbook

I am very new to creating excel Macros. I used a guide to create a Insert Date macro. I then inserted a small picture of a calendar and assigned my macro to it. The function works perfectly fine on ...

Asked Anonymously: Macro Photography???

What are some great spots in Africa for Macro photography?

Asked: How do i get column a to the left side in excel ...

How do i get column a to the left side in excel 2003