#1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Run

Is it possible to run a macro each time the value changes
in a cell.

Thank You,
  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Run

Also, I would be refering to a specific cell


-----Original Message-----
Is it possible to run a macro each time the value changes
in a cell.

Thank You,
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Run

Hi
use a worksheet_change event for this. See:
http://www.cpearson.com/excel/events.htm

--
Regards
Frank Kabel
Frankfurt, Germany


wrote:
Is it possible to run a macro each time the value changes
in a cell.

Thank You,

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Run

Look at Worksheet_Change(ByVal Target As Range).

Target will be the range where the change that tripped this code happened. Check if the range is the cell you are interested in and process accordingly.

- Steve

" wrote:

Is it possible to run a macro each time the value changes
in a cell.

Thank You,

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Run

Is it possible to run a macro each time the value changes
in a cell?


If the value change is by user input, then yes. Each worksheet
has a Worksheet_Change event procedure. Put your code there
or call the macro from there, e.g.:

Sub Worksheet_Change(Target As Range)
If Target.Address = "$A$1" then Macro1
End Sub

If the value change is by a calculation, then it isn't easy. Find a
workaround or repost.

HTH,
Merjet





  #6   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Run


is there a reason why this macro is not completing? I am
using your suggested change event to open or run my other
macro. I probably could use it in the change event macro,
but it does not work there - so I tried this. The problem
is that it stops running the second macro at the
clearcontents and does not complete placing the ones in
the column B. Also, the GETVALS macro does work alone on a
sheet that is not part of the change event macro


Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.Run ("GETVALS")
Else
End
End If
End Sub

''''then in a module''''

Sub GETVALS()
Range("B:B").Select
Selection.Clear
Range("B1").Select
Vals = Range("a1").Value
Range("B1", Cells(Vals, 2)).Value = "1"
End Sub










-----Original Message-----
Is it possible to run a macro each time the value

changes
in a cell?


If the value change is by user input, then yes. Each

worksheet
has a Worksheet_Change event procedure. Put your code

there
or call the macro from there, e.g.:

Sub Worksheet_Change(Target As Range)
If Target.Address = "$A$1" then Macro1
End Sub

If the value change is by a calculation, then it isn't

easy. Find a
workaround or repost.

HTH,
Merjet



.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Run

The problem is that GetVals produces changes on the
same worksheet that results in Worksheet_Change
starting again before it was completes its first execution.

HTH,
Merjet



  #8   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Run

Thanks,

Is there a workaround to allow GetVals to complete



-----Original Message-----
The problem is that GetVals produces changes on the
same worksheet that results in Worksheet_Change
starting again before it was completes its first

execution.

HTH,
Merjet



.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Run

Is there a workaround to allow GetVals to complete

You can try putting this at the start:

With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
.DisplayAlerts = False
End With

and this at the end:

With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
.DisplayAlerts = True
End With

HTH,
Merjet



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



All times are GMT +1. The time now is 03:51 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"