Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / August 2007

Tip: Looking for answers? Try searching our database.

Execute code by changing a Cell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gatarossi@ig.com.br - 12 Aug 2007 14:37 GMT
Dear all,

I need that excel execute some VBA code when I change the value of a
cell in a sheet...

How can I do it?

Thanks a lot !!!

André.
Don Guillett - 12 Aug 2007 15:14 GMT
right click sheet tab>view code>left window select worksheet>right window
select worksheet_change
write code. You probably will want to restrict to a cell or range.

Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

Dear all,

I need that excel execute some VBA code when I change the value of a
cell in a sheet...

How can I do it?

Thanks a lot !!!

André.
gatarossi@ig.com.br - 12 Aug 2007 15:21 GMT
Dear Don Guillett,

If I want that the code execute when I change a cell, how can I do it?

And If I have more than one cell? For example, If when I change
cells(1,1) do it...
and when I change cells (2,1) do another code...

Thanks a lot!!!

André.
Don Guillett - 12 Aug 2007 15:53 GMT
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then MsgBox "High"
If Target.Address = "$A$2" Then MsgBox "Low"
End Sub

Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

Dear Don Guillett,

If I want that the code execute when I change a cell, how can I do it?

And If I have more than one cell? For example, If when I change
cells(1,1) do it...
and when I change cells (2,1) do another code...

Thanks a lot!!!

André.
Earl Kiosterud - 12 Aug 2007 17:34 GMT
André,

Roger has given you the code to cause your code to run when a particular cell has been
changed.  If it's a range of cells, like an entire column, here's an oft-used technique:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect( Target, Range("A:A")) is Nothing then
   ' your code here
   End If
End Sub
Signature

Earl Kiosterud
www.smokeylake.com

   Note: Top-posting has been the norm here.
   Some folks prefer bottom-posting.
   But if you bottom-post to a reply that's
   already top-posted, the thread gets messy.
   When in Rome...
-----------------------------------------------------------------------

Dear all,

I need that excel execute some VBA code when I change the value of a
cell in a sheet...

How can I do it?

Thanks a lot !!!

André.
CLR - 13 Aug 2007 13:40 GMT
Here's one I got from Mudraker awhile back that will run a different macro
depending on the value entered in A2

Private Sub Worksheet_Change(ByVal Target As Range)
'By Mudraker 3/26/06
If Target.Address = "$A$2" Then
Application.EnableEvents = False
Select Case Target.Value
Case "Purchase"
Call macroA
Case "Sales"
Call MacroB
End Select
End If
Application.EnableEvents = True
End Sub

Vaya con Dios,
Chuck, CABGx3

> Dear all,
>
[quoted text clipped - 6 lines]
>
> André.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.