![]() |
Click-event question
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?? |
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?? |
Click-event question
It depends on how you are starting the macro in the workbook on the server.
If it is a Workbook_Open event macro, then the code would have to look at all the open workbooks to find one that met some specific criteria (like had a command button with a specific caption on the activesheet). If you use Application.Run, you could pass in the value from cell A1 as an argument. (the procedure started with application.Run would need to be designed to accept the argument, of course). -- Regards, Tom Ogilvy "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?? |
All times are GMT +1. The time now is 08:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com