+ Reply to Thread
Results 1 to 4 of 4

Problem with use of MOD

  1. #1
    Registered User
    Join Date
    09-13-2010
    Location
    Norway
    MS-Off Ver
    Excel 2007
    Posts
    6

    Problem with use of MOD

    Hi,

    I have a cell "A1" where you are only allowed to type a number which can be divided by "1,5"

    I am using a 'helping cell' A2 where I use the formula
    Please Login or Register  to view this content.
    This will give A2 the value 0 whenever A1 can be divided by 0.

    So far, so good..

    Then the problem starts:
    A1 is being controlled by a UserForm TextInput.
    I have set TextInput.ControlSource to A1

    When the user is changing the value of TextInput, and A2 <> 0 then a loop is starting.
    Cell A1 is supposed to decrease with 0,1 until A2 = 0

    Here is the code:

    Please Login or Register  to view this content.
    I set a break point inside the loop to see what is going on:

    A1 is set to for example 1,7
    A2 become 0,2

    A1 is then corrected to 1,6
    A2 become 0,1

    A1 is corrected to 1,5
    Now A2 SHOULD become 0, and the loop should exit
    A2 becomes -2,22E-16 (!!!)

    I don't understand this!


    Do you?
    Help is very much appreciated

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Problem with use of MOD

    Using ControlSource means the cell reflects changes in the Userform textBox, and vice versa. Each change is probably triggering another change hence the loop
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    09-13-2010
    Location
    Norway
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Problem with use of MOD

    Not sure I understand you, Roy..


    My plan 'is' to reflect the changes.

    I want the Text Input to change the value of A1.
    But I also want the cell value to be written back to the Text Input.

    How do you think I could do this another way?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Problem with use of MOD

    As the TextBox changes, so the cell changes. This in turn will change the textbox, and so on

+ 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