+ Reply to Thread
Results 1 to 3 of 3

Something missing in my code to run macro when 2 cells change

  1. #1
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Portugal
    MS-Off Ver
    Excel 2003
    Posts
    119

    Something missing in my code to run macro when 2 cells change

    I guys

    I have this code that should run a advanced filter when the data in M4 and N4 changes, this is in sheet1. In M4 i have a formula to calculate a result and in N4 is a link from other cell in other sheet (sheet2). What i need is that when the M4 or/and N4 changes my code runs, and this code is in sheet1.
    What am i missing here? With this code it will only change when i click M4 or N4.

    Thanks in advance

    Please Login or Register  to view this content.
    Last edited by bazofio; 01-24-2014 at 10:42 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Something missing in my code to run macro when 2 cells change

    1) You'll need to use the Worksheet_Calculate event.
    2) You'll need to store the values of M4 and N4 somewhere static so you have something to compare to. For this exercise, I'll store them in AM4 and AN4 for the time being.

    Put this code into the Sheet module:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Portugal
    MS-Off Ver
    Excel 2003
    Posts
    119

    Re: Something missing in my code to run macro when 2 cells change

    Thanks for the help JBeaucaire.
    I just don't understand what you mean in point 2. Get them static how? I get them from another sheet, in M4 there is a formula ( =INT(L4/5/1000)*5) that gives me the result that i want to find (L4 is a link from a value in C6 in sheet2), and in N4 is a link to a value in E6 in sheet2.
    Last edited by bazofio; 01-24-2014 at 10:55 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro is missing code to copy formulas as well as values
    By Alana L in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2013, 11:04 AM
  2. Excel Macro to find missing dates and insert missing date as blank row
    By JevaMarie in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-26-2013, 11:08 AM
  3. Problem with midnight date change using VBA macro for adding missing dates
    By ABoon86 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2012, 10:20 AM
  4. Replies: 15
    Last Post: 04-17-2012, 08:19 AM
  5. [SOLVED] Missing floating Macro Toolbar. Can't change to relative referenc
    By GLovell in forum Excel General
    Replies: 1
    Last Post: 06-16-2005, 07:05 PM

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