+ Reply to Thread
Results 1 to 3 of 3

Running a macro if more than one cell changes?

  1. #1
    Registered User
    Join Date
    03-17-2006
    Posts
    44

    Running a macro if more than one cell changes?

    Hi all,

    I have a sheet, and need to run several instances of "If a cell changes value, THEN run a command"

    I can do a single one fine :

    Please Login or Register  to view this content.
    but i also need to put in something like:

    If the value of C2 = "Clear Sheets" then ....
    If the value of C2 = "Save" then...
    IF the value of C2 = "Save and Email" then..

    how would i make this happen?

    Thank you all so much

  2. #2
    Registered User
    Join Date
    03-17-2006
    Posts
    44
    OK so lots of trial and error later, i have managed to do it..

    Please Login or Register  to view this content.


    BUTTTTTTTT


    When i ask it to change cell D2 back to "Options..." it sees the cell has changed, and just runs the macro again!

    Anyway of bypassing it?

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Your macro actions the macro based on D2 contents every time any entry on your sheet is changed.

    I not sure if that is what you are after or just to run when the contents of D2 is changed
    If you require it to run on every cell change then replace
    For Each Cell In Target
    If Not Intersect(Target, Range("d2")) Is Nothing Then
    with
    For Each Cell In Range("D2:D2")

    I have made some changes to the macro so it runs when D2 is changed.
    I have also added some modifications to your If statements.

    Re your origenal question add
    Application.EnableEvents = False
    at the start of your code.
    You must also make sure that the macro runs
    Application.EnableEvents = True
    Otherwise the macro will stop working and so will any other macro's that use trigger events to run them.


    The macro runs quicker if you declare Cell as a Range instead of declaring Cell as Object
    Have a look at
    http://www.cpearson.com/excel/variables.htm
    Especially the Don't Use Object Type Variables section

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1