Results 1 to 10 of 10

VBA Skipping lines of code.

Threaded View

  1. #1
    Registered User
    Join Date
    03-15-2017
    Location
    United States
    MS-Off Ver
    2016
    Posts
    63

    VBA Skipping lines of code.

    I have already done some research and seen what people have posted in the past and I cannot find a solution to this problem. Here is my code. Its pretty simple and bare.

    Sub namees()
    
    For r = 1 To 1099
    
        For n = 1 To 315
          
            Debug.Print r & " " & "|||" & " " & n
    
            If Sheets("Sheet1").Cells(r, 13).Value = Sheets("Sheet2").Cells(n, 2).Value Then
            
                Sheets("Sheet2").Cells(n, 8).Select
                With Selection.Interior
                .Pattern = xlSolid
                .PatternColorIndex = xlAutomatic
                .Color = 255
                .TintAndShade = 0
                .PatternTintAndShade = 0
                End With
                Exit For
                
            End If
            
            If r = 1092 And n = 311 Then
            MsgBox "here"
            End If
            
        Next n
    
    Next r
    
    End Sub
    You can test this code with 2 blank sheets. It never reads the If r = 1092 And n = 311 Then. Why does it do this? I mentioning this line because if it read this line, then it would execute the other if statement above. But it skips just about all of it, but counts correctly in debug.print.

    Edit: Also, if I run the entire code using F8 then it works like it's suppose to.
    Last edited by schulzy175; 02-15-2018 at 03:14 PM. Reason: Added Note

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Is VBA skipping lines of code?
    By JonathanEngr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-21-2018, 06:48 PM
  2. [SOLVED] Sub is skipping lines of code after Then statement
    By chavez982 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-05-2012, 10:32 PM
  3. [SOLVED] How do I allow for skipping lines between dates??
    By n2music in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-10-2012, 10:28 AM
  4. return results without skipping lines.
    By mjhopler in forum Excel General
    Replies: 2
    Last Post: 07-13-2010, 04:01 AM
  5. Copy a formula skipping lines
    By JapanDave in forum Excel General
    Replies: 3
    Last Post: 06-01-2010, 05:11 AM
  6. [SOLVED] Need help in numbering a column while skipping lines
    By Gary Reger in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-21-2005, 06:10 PM

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