Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Automatic Macro Execution Upon Cell Values Changing

I need to have a method to have a macro automatically run whenever a specific
range of cells change. I am not a great VBA programmer so hopefully this is
easy to do.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default Automatic Macro Execution Upon Cell Values Changing

Hi Brian,

I need to have a method to have a macro automatically run whenever a specific
range of cells change. I am not a great VBA programmer so hopefully this is
easy to do.


Sure. Go to the VBE, find the code module for the sheet, select 'Worksheet' in
the top-left dropdown of the code window and the Change event in the top-right.
Then put some code in that event. In the code below, I've assumed you've named
the range to check 'rngChanges':

Private Sub Worksheet_Change(ByVal Target As Range)

Dim rngCells As Range

'Get the cells that have changed within our range
Set rngCells = Application.Intersect(Target, Me.Range("rngChanges"))

If Not rngCells Is Nothing Then
'rngCells points to the cell(s) that have changed within the range
rngCells.Interior.ColorIndex = 3
End If

End Sub


Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatic Macro Execution Upon Cell Values Changing


Brian,

I just want the code in the change event to run if a certain cell (e.
C5) is changed.

how do I tell the worksheet_change event that it should only run if c
is changed

--
wardide
-----------------------------------------------------------------------
wardides's Profile: http://www.excelforum.com/member.php...fo&userid=1502
View this thread: http://www.excelforum.com/showthread.php?threadid=27724

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default Automatic Macro Execution Upon Cell Values Changing

Hi Wardides,

how do I tell the worksheet_change event that it should only run if c5
is changed ?


It will always run - you have to test the Target parameter to see if
it's the one you want - such by checking its address, or seeing if it's
inside a named range.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk


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
How to automatic calculation and macro execution between 3 workbooks? c Excel Worksheet Functions 1 July 22nd 05 05:38 AM
Changing cell values between columns with macro spolk Excel Programming 1 February 18th 04 12:48 PM
Automatic execution of macro Paul-André Gollier Excel Programming 1 January 30th 04 09:03 PM
automatic macro execution Jos reulen Excel Programming 4 November 10th 03 03:10 PM


All times are GMT +1. The time now is 11:20 AM.

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"