In my opinion (for whatever that is worth) if the code for the button only
applies to this one sheet then It belongs in the sheet (where sparker has
it). If the code is more generic and could be used by many sheets and modules
then it belongs in a module. Depends entirely on the scope from my
standpoint, but I probably should have noted your solution also. Good point.
--
HTH...
Jim Thomlinson
"bhofsetz" wrote:
Personally I would put the code behind the button click event into a
standard module as a subroutine. Then I would use the button click
event to call that subroutine. Then you can also call the same sub
from another function or macro.
ie, change this:
Private Sub CommandButton1_Click()
'Your code here
End Sub
to:
'In the code behind the sheet
Private Sub CommandButton1_Click()
ButtonCode
End Sub
'In a standard code module
Sub ButtonCode
'Your code here
End Sub
Then you can call the ButtonCode sub from any function of subroutine
--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=381403