Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
SLE SLE is offline
external usenet poster
 
Posts: 2
Default How do I run a macro from a event structure?

I have a macro and I can off cause run it from "Alt + F8". But how can I run
the mecro each time the cell B2 is changing value?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 367
Default How do I run a macro from a event structure?

On Dec 19, 3:43 pm, SLE wrote:
I have a macro and I can off cause run it from "Alt + F8". But how can I run
the mecro each time the cell B2 is changing value?


Put following code in your worksheet module:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$B$2" Then
YourMacro
End If

End Sub

If you have more than one cell you could also use a select case
statement.

hth

Carlo
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default How do I run a macro from a event structure?

How does B2 get changed?

Manually or by calculation?

Event code can be used but type of event is crucial for an answer.


Gord Dibben MS Excel MVP

On Tue, 18 Dec 2007 22:43:01 -0800, SLE wrote:

I have a macro and I can off cause run it from "Alt + F8". But how can I run
the mecro each time the cell B2 is changing value?


  #4   Report Post  
Posted to microsoft.public.excel.misc
SLE SLE is offline
external usenet poster
 
Posts: 2
Default How do I run a macro from a event structure?

B2 is changed by calculation.
Let us say B2 is "=B1".
If I Manualy change the value in B1, then the value in B2 is changed also.
This value change in B2 must create the event that runs the macro.

"Gord Dibben" wrote:

How does B2 get changed?

Manually or by calculation?

Event code can be used but type of event is crucial for an answer.


Gord Dibben MS Excel MVP

On Tue, 18 Dec 2007 22:43:01 -0800, SLE wrote:

I have a macro and I can off cause run it from "Alt + F8". But how can I run
the mecro each time the cell B2 is changing value?



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default How do I run a macro from a event structure?

I've been away a couple of days.

I am surprised you have not received an answer.

Try this in the sheet module.

Private Sub Worksheet_Calculate()
On Error GoTo stoppit
Application.EnableEvents = False
With Me.Range("B2")
If .Value < "" Then
Call themacroname
End If
End With
stoppit:
Application.EnableEvents = True
End Sub


Gord

On Wed, 19 Dec 2007 22:44:01 -0800, SLE wrote:

B2 is changed by calculation.
Let us say B2 is "=B1".
If I Manualy change the value in B1, then the value in B2 is changed also.
This value change in B2 must create the event that runs the macro.

"Gord Dibben" wrote:

How does B2 get changed?

Manually or by calculation?

Event code can be used but type of event is crucial for an answer.


Gord Dibben MS Excel MVP

On Tue, 18 Dec 2007 22:43:01 -0800, SLE wrote:

I have a macro and I can off cause run it from "Alt + F8". But how can I run
the mecro each time the cell B2 is changing value?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Event Macro running another macro inside K1KKKA Excel Discussion (Misc queries) 1 December 20th 06 08:21 PM
Change event Macro Mike Rogers Excel Discussion (Misc queries) 1 August 20th 06 05:29 AM
It seems to me that I need an event Macro, nick s Excel Worksheet Functions 8 November 28th 05 05:37 PM
'Event' macro George Gee New Users to Excel 18 August 27th 05 12:50 PM
Event Macro stevepain Excel Discussion (Misc queries) 6 August 5th 05 05:11 AM


All times are GMT +1. The time now is 01:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"