#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default start macro

How do I start a macro whenever the contents in a cell is added or changed?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default start macro

hi
use the worksheet change event
right click the sheet tab and from the popup select view code which will
bring up the vb editor
in the left combo box above the code window, select worksheet.
put your code there. it will fire whenever data changes on the sheet.

regards
FSt1
"ranswert" wrote:

How do I start a macro whenever the contents in a cell is added or changed?
Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default start macro

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Call your_macro
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"ranswert" wrote in message
...
How do I start a macro whenever the contents in a cell is added or
changed?
Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default start macro

Hi ranswert

You can use the change event in the sheet module
"YourMacroName" is the name of your sub


Private Sub Worksheet_Change(ByVal Target As Range)
Call YourMacroName
End Sub

See this page also if you have no idea where to paste this
http://www.rondebruin.nl/code.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"ranswert" wrote in message ...
How do I start a macro whenever the contents in a cell is added or changed?
Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default start macro

Is there a way to run the macro only when a certain cell is changed not the
whole sheet?

"FSt1" wrote:

hi
use the worksheet change event
right click the sheet tab and from the popup select view code which will
bring up the vb editor
in the left combo box above the code window, select worksheet.
put your code there. it will fire whenever data changes on the sheet.

regards
FSt1
"ranswert" wrote:

How do I start a macro whenever the contents in a cell is added or changed?
Thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default start macro

hi
yes there is. bob just posted a solution.

regards
FSt1

"ranswert" wrote:

Is there a way to run the macro only when a certain cell is changed not the
whole sheet?

"FSt1" wrote:

hi
use the worksheet change event
right click the sheet tab and from the popup select view code which will
bring up the vb editor
in the left combo box above the code window, select worksheet.
put your code there. it will fire whenever data changes on the sheet.

regards
FSt1
"ranswert" wrote:

How do I start a macro whenever the contents in a cell is added or changed?
Thanks

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
Sub Macro vrs Function Macro Auto Start Pat Excel Discussion (Misc queries) 7 June 6th 07 09:53 PM
How to start a Macro Rick_T Excel Discussion (Misc queries) 1 December 28th 06 04:50 PM
Macro Start zephyr Excel Discussion (Misc queries) 0 November 13th 06 05:01 PM
start a macro johnT Excel Worksheet Functions 2 March 6th 05 06:43 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 04:05 PM.

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

About Us

"It's about Microsoft Excel"