Thread: Module problem
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rob Bovey Rob Bovey is offline
external usenet poster
 
Posts: 811
Default Module problem

"Pat" wrote in message
.. .
Thank you for helping out. It seems I need to clarify what precisely I
wish
to do. On one sheet (say, sheet1) a custom commandbutton is clicked to
bring
the user to another sheet (say, sheet2). in sheet2 another custom
commandbutton (called, CloseExcelExport) is clicked which runs code. Once
the code has completed the instructions it then ghosts out the button,
hence
the instruction,

Me.CloseExcelExport.Enabled = False

What I want to do is incorporate the code in CloseExcelExport with the
commandbutton in sheet1, but still retain the commandbutton in sheet2.


Hi Pat,

If you want to address a command button called CloseExcelExport, which
is located on Sheet2, from code located in Sheet1 you would do it like so
(assuming the CodeName of the target worksheet is in fact Sheet2):

Sheet2.CloseExcelExport.Enabled = False

If you want this button and a button on Sheet1 to call the same code,
there are several ways to do it. The easiest would be to create a new method
(Public Sub) in Sheet2 and call it from both places. If you have the
following in Sheet2:

Public Sub MyMethod()
''' Your code here
End Sub

You can call it from Sheet1 like so:

Sheet2.MyMethod

And it can be called from within Sheet2 like any other subroutine.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm