+ Reply to Thread
Results 1 to 3 of 3

for loop only works until first if statement

  1. #1
    Registered User
    Join Date
    11-16-2021
    Location
    Munich, Germany
    MS-Off Ver
    Office 2013
    Posts
    21

    for loop only works until first if statement

    Hello, i have the following vba code where i loop through a range of cells and when i find a specific value i want to copy the value of another cell in the same row.

    It works just fine until the first condition is true in row 14(K33), after that it just goes into the next 6 rows and copies the values of those cells without skipping until the next if statement is true.
    sometimes the jumping into the correct row works as seen in my msgboxes but it still copies the wrong values

    Here is my code:


    Please Login or Register  to view this content.
    Last edited by Erazo; 12-02-2021 at 09:29 AM.

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: for loop only works until first if statement

    How are you triggering the code?
    Rory

  3. #3
    Registered User
    Join Date
    11-16-2021
    Location
    Munich, Germany
    MS-Off Ver
    Office 2013
    Posts
    21

    Re: for loop only works until first if statement

    i trigger it through a button
    I reopend the document and the code magically works now. Weird but ok :D

+ 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. [SOLVED] Works in a Do loop, but how to convert to For loop?
    By OpieWinston in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2021, 01:15 PM
  2. [SOLVED] Loop code through two works
    By mrsak87 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-21-2020, 10:17 AM
  3. I'm confused this loop works?
    By TestKing1994 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-12-2019, 04:13 PM
  4. [SOLVED] i have an if then statement that works, how to make it work as a with or case statement
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-03-2016, 03:34 PM
  5. [SOLVED] For Each Loop Works for Textboxes but Not for DTPickers.... why?
    By TheScott in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-03-2015, 06:01 AM
  6. IF statement works for some but not all?
    By refryguy in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-02-2014, 02:04 PM
  7. [SOLVED] if then loop works incorrectly - syntax?
    By canoehack in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-25-2013, 09:31 AM

Tags for this Thread

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