+ Reply to Thread
Results 1 to 7 of 7

Code repeats twice

  1. #1
    Registered User
    Join Date
    09-28-2010
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    13

    Code repeats twice

    Hello,

    I have created an excel sheet to help our employees select the right product for the customer. The first part of the code clears a cell when the employee makes a change to cell A23. The second part of the code operates perfectly when the employee makes changes to any cell other than A23. When the employee changes cell A23, the second part of the code executes twice displaying "Please select another product. Cannot meet the current load!" and "Please select another product." two times in a row.

    Why does it do this?
    Any help would be very appreciated.

    My code is shown below:

    Please Login or Register  to view this content.
    Last edited by scurveydog; 11-01-2010 at 05:21 PM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,258

    Re: Code repeats twice

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    09-28-2010
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Code repeats twice

    I apologize. I did remember that I was supposed to put tags around the code, but for whatever reason I could not find the tag button. Thank-you for telling me how to do this.

    My code now has tags around it. I hope this helps everyone.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Code repeats twice

    I don't klnow what logic you're trying to implement; maybe this:

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    09-28-2010
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Code repeats twice

    Sorry I forgot to add a sentence. Please see the code above for the update.

    I will try to clarify this. When I run the first and second part of the code separately they work fine. The first part of the code clears cell A23 when the user makes a change to the spreadsheet. The second part of the code will display "Please select another product. Cannot meet the current load!" if cell E44 is bigger than cell E41 and will display "Please select another product. Product is too small."
    or "Please select another product. Product is too big." if cell E30 is less than 10 or greater than 22 respectively. Nothing is displayed if the value in cell E30 is in between 10 and 22.

    However, when I run the first part and the second part of the code together "Please select another product. Cannot meet the current load!" and "Please select another product. Product is too small." is displayed (if E30 is less than 10) and will repeat itself twice such as:
    "Please select another product. Cannot meet the current load!"
    "Please select another product. Product is too small."
    "Please select another product. Cannot meet the current load!"
    "Please select another product. Product is too small."


    OR

    Please select another product. Cannot meet the current load!" and "Please select another product. Product is too big." is displayed (if E30 is greater than 22) and will repeat itself twice such as:
    Please select another product. Cannot meet the current load!"
    "Please select another product. Product is too big."
    Please select another product. Cannot meet the current load!"
    "Please select another product. Product is too big."

    OR

    "Please select another product. Cannot meet the current load!" is displayed (if E30 falls between 10 and 22.) and will repeat itself twice such as:
    "Please select another product. Cannot meet the current load!"
    "Please select another product. Cannot meet the current load!"

    I hope this clarifies my problem. I don't want it to display the message twice. (once is good enough).
    Let me know if it is still confusing and tell me what you don't understand.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,258

    Re: Code repeats twice

    I suspect you just need to disable events, since you are changing the sheet from the Change event:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-28-2010
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Code repeats twice

    Perfect!!! That's exactly what I wanted. Thanks a lot.

+ 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