+ Reply to Thread
Results 1 to 14 of 14

Cell Changing due to Calculation

  1. #1
    Registered User
    Join Date
    01-20-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    59

    Cell Changing due to Calculation

    I have some cells that change due to calculations via the worksheet_calculate sub. What happens is that a checkbox is check, which changes a cell from false to true. Once 3 checkboxes in a certain range are all checked (true), another cell changes.

    How do I trigger an event to happen when these cells change? I have tried using the worksheet_change sub, but it doesn't work.

    Any advice would e very much appreciated

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Cell Changing due to Calculation

    Why don't you use ActiveX checkbox instead of Form Checkbox?


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    01-20-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Cell Changing due to Calculation

    Quote Originally Posted by :) Sixthsense :) View Post
    Why don't you use ActiveX checkbox instead of Form Checkbox?
    Would that make it easier? Given I've got over 100 checkboxes on the sheet, all linked to different cells, calculations etc, I was hoping to find another solution!

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Cell Changing due to Calculation

    Hi dark,

    1. If a cell is changed manually or by VBA, Workseet_Change() is needed.

    2. If a cell is changed manually or by VBA and the old value is needed:
    a. A global variable is needed to save the old value.
    b. Worksheet_SelectionChange() is needed to identify the value of the old value.
    c. Workseet_Change() is needed to identify the new value, and possibly take further action.

    3. If a range of values is changed by Formula (including a range containing only one cell):
    a. A global array of variables is needed to store the old values.
    b. The global array needes to be initialized by Workbook_Open().
    c. Worksheet_Calculate() is needed to identify which cells in the range changed value.

    See post #3 in the following link for posted code and a sample file which answers your question: http://www.excelforum.com/excel-prog...ionchange.html

    Lewis
    Last edited by LJMetzger; 04-30-2014 at 08:17 AM.

  5. #5
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Cell Changing due to Calculation

    Refer the attached file to know how to do it
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    01-20-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Cell Changing due to Calculation

    Quote Originally Posted by :) Sixthsense :) View Post
    Refer the attached file to know how to do it
    Thanks for that. What I need though is something that runs when cell A1 in your example changes. i.e. when the value in cell A1 changes a message box appears, rather than when the boxes are checked

  7. #7
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Cell Changing due to Calculation

    Wrongly Posted

  8. #8
    Registered User
    Join Date
    01-20-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Cell Changing due to Calculation

    Quote Originally Posted by :) Sixthsense :) View Post
    Wrongly Posted
    What is wrongly posted?

  9. #9
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Cell Changing due to Calculation

    Quote Originally Posted by darkblueblood View Post
    What is wrongly posted?
    Before you see this post I wrongly posted a solution which I arrived for another question.

    Coming back to your question, you may think it is an onclick event running with that check boxes, but actually it is an calculate event which runs whenever any change occurs in formula. In the given example the A1 cell countif formula will trigger the calculate event whenever any change occurs in the linked cells of the check box.

    Hope its clear now

  10. #10
    Registered User
    Join Date
    01-20-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Cell Changing due to Calculation

    Quote Originally Posted by :) Sixthsense :) View Post
    Before you see this post I wrongly posted a solution which I arrived for another question.

    Coming back to your question, you may think it is an onclick event running with that check boxes, but actually it is an calculate event which runs whenever any change occurs in formula. In the given example the A1 cell countif formula will trigger the calculate event whenever any change occurs in the linked cells of the check box.

    Hope its clear now
    Yeah, but the message box is appearing as a result of clicking the checkbox, not as a result of a change of value in A1. I need the message box to appear as a result of A1 changing value

  11. #11
    Registered User
    Join Date
    01-20-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Cell Changing due to Calculation

    Quote Originally Posted by LJMetzger View Post
    Hi dark,

    1. If a cell is changed manually or by VBA, Workseet_Change() is needed.

    2. If a cell is changed manually or by VBA and the old value is needed:
    a. A global variable is needed to save the old value.
    b. Worksheet_SelectionChange() is needed to identify the value of the old value.
    c. Workseet_Change() is needed to identify the new value, and possibly take further action.

    3. If a range of values is changed by Formula (including a range containing only one cell):
    a. A global array of variables is needed to store the old values.
    b. The global array needes to be initialized by Workbook_Open().
    c. Worksheet_Calculate() is needed to identify which cells in the range changed value.

    See post #3 in the following link for posted code and a sample file:
    http://www.excelforum.com/excel-prog...ionchange.html

    Lewis
    I think I have this working to a certain extent, however does anyone know how to set it for a rnage of single cells? i.e. it currently has this code:

    Please Login or Register  to view this content.
    I would want to include it for "AC6", "AC9", "AC12", "AC15", AC18", "AC21", "AC24"

    Any ideas?

  12. #12
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Cell Changing due to Calculation

    Quote Originally Posted by darkblueblood View Post
    Yeah, but the message box is appearing as a result of clicking the checkbox, not as a result of a change of value in A1. I need the message box to appear as a result of A1 changing value
    Please re-read my quoted sentence once again for getting clarity

    Quote Originally Posted by :) Sixthsense :) View Post
    Before you see this post I wrongly posted a solution which I arrived for another question.

    Coming back to your question, you may think it is an onclick event running with that check boxes, but actually it is an calculate event which runs whenever any change occurs in formula. In the given example the A1 cell countif formula will trigger the calculate event whenever any change occurs in the linked cells of the check box.

    Hope its clear now

  13. #13
    Registered User
    Join Date
    01-20-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Cell Changing due to Calculation

    Quote Originally Posted by :) Sixthsense :) View Post
    Please re-read my quoted sentence once again for getting clarity
    Ok, so how do I change this so that the calculate event only runs when cell A1 is changed, rather than the check boxes?

  14. #14
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Cell Changing due to Calculation

    See the attached file which simulates your condition. Please do not cross post as it does nothing but cause confusion.

    Lewis

    ThisWorkbook module:
    Please Login or Register  to view this content.
    Sheet1 module:
    Please Login or Register  to view this content.

    An ordinary module:
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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. Replies: 1
    Last Post: 01-15-2013, 08:51 AM
  2. Prevent calculation from changing
    By thmehr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2012, 09:33 AM
  3. Changing Slope Calculation
    By alecp in forum Excel General
    Replies: 11
    Last Post: 02-09-2012, 10:31 AM
  4. Calculation: Item changing
    By kuzmi in forum Excel General
    Replies: 4
    Last Post: 03-18-2005, 04:58 AM
  5. Replies: 2
    Last Post: 02-15-2005, 10:06 AM

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