Link to home
Start Free TrialLog in
Avatar of Euro5
Euro5Flag for United States of America

asked on

vba error next without for

I am getting a next without for error message, but I think that the for is line  For i = 1 To LR + 1
This is probably obvious to others, but I cant identify what to fix.
Can anyone help? Thanks!


Sub GroundNet1e()
Application.ScreenUpdating = False
    Sheet3.Activate
Dim Ws As Worksheet
Dim LR As Long
Dim i As Integer
Application.ScreenUpdating = False
Set Ws = ActiveSheet
LR = Ws.Range("A" & Rows.Count).End(xlUp).Row
    Dim rngFindH1 As Range
    Dim rngFindH2 As Range
    Set rngFindH1 = ActiveSheet.Range("A:C").Find("Ground Domestic Single Piece")
    If Not rngFindH1 Is Nothing Then
        Set rngFindH2 = ActiveSheet.Range("A" & rngFindH1.Row + 1 & ":A99999").Find("lbs.")
    Else
        Exit Sub
    End If
    If Not rngFindH2 Is Nothing Then
        Select Case rngFindH2.Row - rngFindH1.MergeArea.Cells(1, 1).Offset(1).Row
            Case Is >= 1
                ActiveSheet.Range("A" & rngFindH1.Row + 1 & ":" & "A" & rngFindH2.Row - 1).EntireRow.Delete
            Case 0
                rngFindH2.EntireRow.Insert
            Case Else
        End Select
    End If
    
For i = 1 To LR + 1
    If Cells(i, 1).Value = "lbs." Then
        If Cells(i, 1).Offset(1, 0).Range("A1") = "" Then
            Cells(i, 1).Offset(1, 0).EntireRow.Delete
        End If
Next i
Application.ScreenUpdating = True

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Euro5

ASKER

Thanks again!
You're welcome.