View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Papa Jonah Papa Jonah is offline
external usenet poster
 
Posts: 148
Default How to add a command button and on-click within vba

My project I am working on does a lot of formating, reorganizing, and
calculations with VBA. When the code is done, I have a sheet that
"summarizes" what has been done through a "grading" scheme that my boss wants.

However, as the end-users analyze the data generated, we tweak the arrays or
ranges as necessary. When we do this, the data underlying the scores change,
thereby affecting the scores.
What I want to do is add a command button to my score sheet that, when
clicked, will re-run the scoring macro and update the scoring summary.

I am able to get the button to appear, but I can not figure out how to tell
the code what I want it to do when I click it.
Where I am getting confused is: I can add the button, change the caption
etc. I can even write the macro for it to follow "on-click". Where I get
lost is - when I try to include this into the vba code that is driving the
whole thing.

Below is the code that is used to draw the button. How do I modify this to
tell it to run the on-click macro?

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Comma ndButton.1",
Link:=False _
, DisplayAsIcon:=False, Left:=31.2, Top:=240.6, Width:=85.2,
Height:= _
33.6).Select