+ Reply to Thread
Results 1 to 5 of 5

Loop problem

  1. #1
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Loop problem

    Hello guys,

    Quick question, how to change the code below so that If I was to select "Bankterminal" as first Item in, for example A13, the MsgBox does not pop up for each and everytime I make A selection in the Range("A14:A40") ?

    In other Words, I only want the MsgBox to pop up ONE time for each time it is ACTUALLY chosen.

    Now, using the code below, for each change I make it will loop through all the cells in Range("A13:A40") and for Each cell containing the value "Bankterminal" the MsgBox will pop up. So If it finds the value "Bankterminal", lets say, 3 times then the MsgBox pops up 3 times.


    Please Login or Register  to view this content.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,824

    Re: Loop problem

    Try:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Re: Loop problem

    Ok, tried it.

    It did indeed eliminate the fact that no matter how many Cells contain "Bankterminal" the pop up will only occur once.

    However, I still have the problem that for example A13 and A14 contain "Bankterminal" the MsgBox will still pop up once for EACH change that is made to any of the Cells in Range(A15:A40), even If I choose totally different values.

    I believe that itīs the fact that ther is A CHANGE that is made (no matter wich change) in the Loop range the pop will occur for each change as long as at least one Cell contains the value "Bankterminal".


    Any other suggestions to fix this last issue?

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,824

    Re: Loop problem

    Is your code in a worksheet_change event or in a regular module? Can you post the whole macro?

  5. #5
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Re: Loop problem

    Yes it is and here it is: (Itīs regarding the last procedure)

    Please Login or Register  to view this content.

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,824

    Re: Loop problem

    Since the loop is part of the change event, it will run automatically whenever you make a change in any cell in the range. There may be a way of making it work the way you want by keeping the loop as part of the change event but I can't think of any way to do it. The only way that I can think of is to take it out of the change event macro, put it into a regular module and run it using a button on your worksheet.

+ 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. Vlookup problem in a loop with cell property and variable cell problem (long title sry)
    By ExcelsiorLux in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-13-2013, 10:38 AM
  2. [SOLVED] Loop inside a loop problem!
    By questionguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-22-2012, 12:54 PM
  3. Problem with Do Loop
    By Loader in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2009, 06:50 AM
  4. [SOLVED] Loop problem
    By Shawn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-12-2005, 07:05 PM
  5. [SOLVED] Problem adding charts using Do-Loop Until loop
    By Chris Bromley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2005, 09: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