Discuss MikeBeer's answer to: How do i add macro in excel to button

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



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()
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="" rel="nofollow" cl="http://www.w3.org/People/Berners-Lee/FAQ#have" class="comlink">FAQ section</a> .
Liked this answer? Tell your friends about it
Add Your Comment (or add your own answer)