ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   OnSheetChange or OnSheetCalculate Event Handler (https://www.excelbanter.com/excel-programming/333549-onsheetchange-onsheetcalculate-event-handler.html)

Erkan

OnSheetChange or OnSheetCalculate Event Handler
 
First of all i don't know english well, i am very sorry therefore... :(

I have 1055 pieces of excel file and i must add some macro them. They our
product's files and they are same files. I have a good idea then this. If i
make an add-in(xla), my problem will finish, but i must learn how can i do
OnSheetCalculate or OnSheetChange event. Becouse i want to control my files
from add-in.

Is there anyone help me about this subjuct...

I will to pray very much how help me...







Erkan

OnSheetChange or OnSheetCalculate Event Handler
 
There is a mistake at the end of my mail. I fix it... :)
Not how, it must be who. :)


"Erkan" , haber iletisinde þunlarý
...
First of all i don't know english well, i am very sorry therefore... :(

I have 1055 pieces of excel file and i must add some macro them. They our
product's files and they are same files. I have a good idea then this. If
i make an add-in(xla), my problem will finish, but i must learn how can i
do OnSheetCalculate or OnSheetChange event. Becouse i want to control my
files from add-in.

Is there anyone help me about this subjuct...

I will to pray very much how help me...









Jim Thomlinson[_4_]

OnSheetChange or OnSheetCalculate Event Handler
 
Events in addins are a little tricky. You need to have a class and a module.
Insert a Class and name it clsEventClass. Add the following code to the class

Option Explicit
Private WithEvents xlApp As Excel.Application

Private Sub Class_Initialize()
Set xlApp = Excel.Application
End Sub

Private Sub xlApp_SheetChange(ByVal Sh As Object, ByVal Target As Range)
MsgBox Sh.Name & vbTab & Target.Address
End Sub

Private Sub xlApp_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI As
Boolean, Cancel As Boolean)
MsgBox "Tada"
End Sub

Now you need to add a module and put the following code in it to create an
instance of the class when the addin loads

Option Explicit
Public evtEvents As clsEventClass

Public Sub Auto_Open()
Set evtEvents = New clsEventClass
End Sub

--
HTH...

Jim Thomlinson


"Erkan" wrote:

There is a mistake at the end of my mail. I fix it... :)
Not how, it must be who. :)


"Erkan" , haber iletisinde þunlarý
...
First of all i don't know english well, i am very sorry therefore... :(

I have 1055 pieces of excel file and i must add some macro them. They our
product's files and they are same files. I have a good idea then this. If
i make an add-in(xla), my problem will finish, but i must learn how can i
do OnSheetCalculate or OnSheetChange event. Becouse i want to control my
files from add-in.

Is there anyone help me about this subjuct...

I will to pray very much how help me...










Erkan

OnSheetChange or OnSheetCalculate Event Handler
 
I don't know how can i thank to you for your valuable help Jim Thomlinson.
You are right. Events in addins subjuct is a little hard for me. I must work
very much on this subjuct. I used your codes and they are running very
good...

You rescue me from a big problem. You are very good person... :)

I hope everything be as you want... :)



"Jim Thomlinson" , haber iletisinde þunlarý
...
Events in addins are a little tricky. You need to have a class and a
module.
Insert a Class and name it clsEventClass. Add the following code to the
class

Option Explicit
Private WithEvents xlApp As Excel.Application

Private Sub Class_Initialize()
Set xlApp = Excel.Application
End Sub

Private Sub xlApp_SheetChange(ByVal Sh As Object, ByVal Target As Range)
MsgBox Sh.Name & vbTab & Target.Address
End Sub

Private Sub xlApp_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI
As
Boolean, Cancel As Boolean)
MsgBox "Tada"
End Sub

Now you need to add a module and put the following code in it to create
an
instance of the class when the addin loads

Option Explicit
Public evtEvents As clsEventClass

Public Sub Auto_Open()
Set evtEvents = New clsEventClass
End Sub

--
HTH...

Jim Thomlinson


"Erkan" wrote:

There is a mistake at the end of my mail. I fix it... :)
Not how, it must be who. :)


"Erkan" , haber iletisinde ?unlary
...
First of all i don't know english well, i am very sorry therefore... :(

I have 1055 pieces of excel file and i must add some macro them. They
our
product's files and they are same files. I have a good idea then this.
If
i make an add-in(xla), my problem will finish, but i must learn how can
i
do OnSheetCalculate or OnSheetChange event. Becouse i want to control
my
files from add-in.

Is there anyone help me about this subjuct...

I will to pray very much how help me...













All times are GMT +1. The time now is 01:31 PM.

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