Results 1 to 5 of 5

Macro stops too early - Help!

Threaded View

  1. #1
    Registered User
    Join Date
    02-01-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2010
    Posts
    97

    Macro stops too early - Help!

    Hi Everyone,

    I have a macro that inserts a new line under certain conditions (where "RAN" is shown)

    The problem I have is that it works perfectly for the first 46 rows but will not work thereafter.

    Can anyone help and advise where the issue is?

    Thanks

    Heres the code:-

    Option Explicit
    
    Sub new_inspection()
    Dim lrow As Long, i As Long
    
    With Worksheets("Sheet1")
        lrow = .Range("A" & .Rows.Count).End(xlUp).Row
        For i = 2 To lrow
            If .Range("W" & i).Value = "RAN" Then
                .Rows(i + 1).Insert
                .Range("A" & i & ":R" & i).Copy .Range("A" & i + 1)
                .Range("R" & i + 1).Value = "7G"
                .Range("W" & i + 1).Value = "RAN"
                i = i + 1
                lrow = lrow + 1000
            End If
        Next i
    End With
    
    End Sub
    Last edited by cossie2k; 06-25-2012 at 07:52 AM.

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