+ Reply to Thread
Results 1 to 4 of 4

Code executes 8 times without loop statements. Why?

  1. #1
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Smile Code executes 8 times without loop statements. Why?

    Hi all

    I was playing aroung some VBA code, but the code executes 98 times and I don't know why.

    For example, range A1 contains 5. When I type, say 3, in A1, I want A1 to show me 8 (5+3). Then I may type 10, in this case A1 must show 18 (8+10). And so on.

    I decided to place entered values in different column, then sum them in A1 with below stated code

    Please Login or Register  to view this content.
    But this code executes 97 times, and I can't figure out why?! I just want to know the reason of this behaviour...
    Attached Files Attached Files
    Last edited by contaminated; 02-08-2010 at 05:03 PM.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Code executes 8 times without loop statements. Why?

    just bumping that

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Code executes 8 times without loop statements. Why?

    With worksheet_change macros, if you write to the worksheet you REtrigger the event code. Not all ws-Change macros make changes to the actual sheet, but if you do, you need to disable events so that no other macros trigger until the routine completes.

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Code executes 8 times without loop statements. Why?

    PERFECT!!!!!!!!!!!!!!
    Tanks for explanation....

+ 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