+ Reply to Thread
Results 1 to 11 of 11

Run macro when cell value changes

  1. #1
    Forum Contributor
    Join Date
    12-06-2012
    Location
    sacramento,calif
    MS-Off Ver
    Excel 2010
    Posts
    217

    Run macro when cell value changes

    I have check boxes down Col. A and a cell that references the check box linked cell (same cell as check box) in Col. T.

    When any check box cell = True, the corresponding cell in Col. T will = 1.

    I want a macro to run when any cell in col T = 1 by using Worksheet_Change(ByVal Target As Range)

  2. #2
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Run macro when cell value changes

    Hi,

    See image attached.
    You need to place code into the Worksheet_Change event handler that you can access by right clicking on the sheet tab and choosing View Code from the context menu.
    Attached Images Attached Images
    Regards,
    Rudi

  3. #3
    Forum Contributor
    Join Date
    12-06-2012
    Location
    sacramento,calif
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: Run macro when cell value changes

    Quote Originally Posted by RudiS View Post
    Hi,

    See image attached.
    You need to place code into the Worksheet_Change event handler that you can access by right clicking on the sheet tab and choosing View Code from the context menu.
    Hi, I think you misunderstand, I know how to get code in the VBA. I need a solution for the problem I explained in my post.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Run macro when cell value changes

    I am confused by your request in the first post. What do you want the VBA to do? You indicate that when any textbox in column A = True then Corresponding value in Column T= 1.

    Then you ask
    I want a macro to run when any cell in col T = 1
    What do you want the macro to do? What am I missing here in your request?
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Run macro when cell value changes

    Hi,

    In your post you say:
    I want a macro to run when any cell in col T = 1 by using Worksheet_Change(ByVal Target As Range)

    That is not much of a description of what you want the code to do?
    All I can provide is the skeleton of the event. You will need to provide more info about what must be done if the value in column T becomes 1.

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    12-06-2012
    Location
    sacramento,calif
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: Run macro when cell value changes

    Quote Originally Posted by RudiS View Post
    Hi,

    In your post you say:
    I want a macro to run when any cell in col T = 1 by using Worksheet_Change(ByVal Target As Range)

    That is not much of a description of what you want the code to do?
    All I can provide is the skeleton of the event. You will need to provide more info about what must be done if the value in column T becomes 1.

    Please Login or Register  to view this content.
    I'll try that, brb...

  7. #7
    Forum Contributor
    Join Date
    12-06-2012
    Location
    sacramento,calif
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: Run macro when cell value changes

    Quote Originally Posted by RudiS View Post
    Hi,

    In your post you say:
    I want a macro to run when any cell in col T = 1 by using Worksheet_Change(ByVal Target As Range)

    That is not much of a description of what you want the code to do?
    All I can provide is the skeleton of the event. You will need to provide more info about what must be done if the value in column T becomes 1.

    Please Login or Register  to view this content.
    Ok, your code works (I put a msgbox where macro will be) but only if I manually type a 1 in a cell in Column T, I am trying to activate the macro by clicking a check box in column A which changes the value in the cell in Column T to a 1 but this by itself will not activate the macro.

    Btw, the only range I need in Column T is T9:T72

  8. #8
    Forum Contributor
    Join Date
    12-06-2012
    Location
    sacramento,calif
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: Run macro when cell value changes

    Quote Originally Posted by alansidman View Post
    I am confused by your request in the first post. What do you want the VBA to do? You indicate that when any textbox in column A = True then Corresponding value in Column T= 1.

    Then you ask

    What do you want the macro to do? What am I missing here in your request?
    Example, in Cell T17: =IF(AND(A17=TRUE,D17="NONE"),1,"")

    cell A17 is a checkbox, so I want the macro to run when I click on the checkbox in A17 (changing it to True) and T17 = 1

  9. #9
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Run macro when cell value changes

    Hi,

    OK...it is not "changed", as a formula is updating it. in this respect, it is the "calculate" event that must be used.
    I had to use a loop to check any cell in your range if it becomes a one. Usually though, if you use controls on a sheet or a userform, the code sits under the control, similar to...If CheckBox1.Value = TRUE then MsgBox "Run the macro"

    Use the following:

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    12-06-2012
    Location
    sacramento,calif
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: Run macro when cell value changes

    Quote Originally Posted by RudiS View Post
    Hi,

    OK...it is not "changed", as a formula is updating it. in this respect, it is the "calculate" event that must be used.
    I had to use a loop to check any cell in your range if it becomes a one. Usually though, if you use controls on a sheet or a userform, the code sits under the control, similar to...If CheckBox1.Value = TRUE then MsgBox "Run
    the macro"

    Use the following:

    Please Login or Register  to view this content.
    Excellent, thanks.

  11. #11
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Run macro when cell value changes

    You're welcome

+ 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 Delete Contents in 23rd corresponding cell if the cell in range is a non-blank cell
    By murtaza.khan in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-04-2014, 01:11 AM
  2. macro to run a macro for evrey cell in column depending upon valuein cell
    By swaptul in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-09-2014, 06:55 PM
  3. Replies: 1
    Last Post: 11-06-2013, 02:56 AM
  4. Cell Rounding Macro - significant digits is variable from cell to cell
    By schmidt62 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-04-2012, 05:06 PM
  5. [SOLVED] creating a macro that inserts the current date in the same cell everytime the macro is run
    By katie1994 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-14-2012, 07:59 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