ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   how can i call a sub() automatically when someone click on sheet1 (https://www.excelbanter.com/excel-worksheet-functions/8868-how-can-i-call-sub-automatically-when-someone-click-sheet1.html)

Saadi

how can i call a sub() automatically when someone click on sheet1
 
Hi

I have a function, that is to be called when someone click on the sheet1.
can someone tell me how do I do this.

the name of that sub is FindRelatedVal()

Sub FindRelatedVal()
............................
End Sub

Jimbola

You can attach the function (macro) to the activate worksheet event for sheet
one.
In the visual basic editor click sheet1 on the left explorere window, then
in the code window on the right where the drop down list says declaration
change that to This Workbook, then on the right dropdown lists select
Activate.
Add your code and it should run when you click sheet1.

HTH

"Saadi" wrote:

Hi

I have a function, that is to be called when someone click on the sheet1.
can someone tell me how do I do this.

the name of that sub is FindRelatedVal()

Sub FindRelatedVal()
............................
End Sub


Saadi

It Worked thanks Jimbola.

"Jimbola" wrote:

You can attach the function (macro) to the activate worksheet event for sheet
one.
In the visual basic editor click sheet1 on the left explorere window, then
in the code window on the right where the drop down list says declaration
change that to This Workbook, then on the right dropdown lists select
Activate.
Add your code and it should run when you click sheet1.

HTH

"Saadi" wrote:

Hi

I have a function, that is to be called when someone click on the sheet1.
can someone tell me how do I do this.

the name of that sub is FindRelatedVal()

Sub FindRelatedVal()
............................
End Sub



All times are GMT +1. The time now is 03:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com