+ Reply to Thread
Results 1 to 5 of 5

Want to call Macro when cell changes as a result of Combo Box Choice

  1. #1
    Valued Forum Contributor
    Join Date
    02-04-2009
    Location
    Texas
    MS-Off Ver
    Excel 2016
    Posts
    665

    Want to call Macro when cell changes as a result of Combo Box Choice

    I have a combo Box that is tied to E6 - so based on the combo box choice E6 becomes 1-4

    I have a macro that changes the value of a cell based on E6 (running fine)

    Please Login or Register  to view this content.
    I need macro that runs MpsCalc whenever the number in E6 changes. This is what I am trying:
    Please Login or Register  to view this content.
    I have both of these in Sheet1 (the sheet that changes)

    What is going wrong with calling the macro?


    Thanks
    Last edited by CRIMEDOG; 09-17-2012 at 08:54 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Want to call Macro when cell changes as a result of Combo Box Choice

    I can't see anything here that would prevent this from working. I would be happy to look at it if you could attach your workbook. Have you tried to walk through it with the debugger to see if it's getting executed the way you think it is? For example, if you did some debugging and ended up calling
    Please Login or Register  to view this content.
    but an error occurred and you never got to the line of code setting it back to True, then that setting "sticks" and has to be reset manually by making the call in the Immediate window (or by closing and re-opening Excel).

    I do have a couple of suggestions. First, using strings for arithmetic is not a particularly good practice. I would use the form below:

    Please Login or Register  to view this content.
    Second, your test for what cell is changing is lengthier than necessary to check for a single cell, here is one alternative. The bracketed expression [x] is equivalent to

    Range("x")

    This is really more for readability than anything else and is a matter of personal taste, just wanted to offer it:
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Valued Forum Contributor
    Join Date
    02-04-2009
    Location
    Texas
    MS-Off Ver
    Excel 2016
    Posts
    665

    Re: Want to call Macro when cell changes as a result of Combo Box Choice

    Okay - I have attached the workBook. I have been trying it several ways.
    I use a combo box to change E7 - When E7 Changes I would like the macro to run
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    02-04-2009
    Location
    Texas
    MS-Off Ver
    Excel 2016
    Posts
    665

    Re: Want to call Macro when cell changes as a result of Combo Box Choice

    When I manually change the cell - the macro works
    When I change it using the combo box it doesn't.

    So - I guess how do you get the Sheet to recognize the change is the question

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Want to call Macro when cell changes as a result of Combo Box Choice

    Change MpsCalc from Private to Public. Now go into Design mode and right-click on the combobox, and select "Assign Macro...". Select MspCalc from the list. Now whenever the value selected in the combobox changes, it will automatically call MpsCalc.
    Last edited by 6StringJazzer; 09-15-2012 at 09:30 PM.

+ 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