View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Click-event question

Steph,

I have to assume that you put a commandbutton from the Control Toolbox onto
a sheet, since sheets don't have a click event.

If you do have a commandbutton, then you simply use Me, which is the object
containing the code (the worksheet).

Private Sub CommandButton1_Click()
MsgBox Me.Range("A1").Value
End Sub

You can certainly assign that to a variable to be used after the other
workbook is opened.

HTH,
Bernie
MS Excel MVP

"Steph" wrote in message
...
Hello. I have a workbook with a single sheet and a click event on that
sheet. The click event opens a different workbook that resides on the
server and runs a procedure that is housed in the newly opened workbook.

When the newly opened macro is executed, I need to know where the
click-event originated from. I have the file owners name in cell A1. I
would like to read the contents of cell A1 (the sheet name will vary with
different files) in the file that houses the click event, and be able to

use
that variable in the code in the workbook that the click event opened.

Can
this be done?? Thanks.

So basically the click event fires, and the newly opened workbook can pop

up
a message box that says "this workbook was opened by <var" where <var

is
the value in Cell A1 of the click-event workbook.

Possible??