Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Deleting Rows with Range from Listbox

Status
Not open for further replies.

plawrenz

Programmer
May 4, 2012
1
US
I need the range to go from A150 to A7 since its current state it missed rows if there are multiple rows that need to be deleted.

With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then


Set r1 = Range("A7:A150")
For Each c1 In r1

If c1.Value = .List(i) Then
c1.Font.Bold = True
With c1
c1.EntireRow.Delete
End With
End If

Next c1

End If
Next i
End With
 
What about this ?
Code:
With ListBox1
    For i = 0 To .ListCount - 1
        If .Selected(i) Then
            For r = 150 To 7 Step -1
                If Cells(r, 1).Value = .List(i) Then
                    Rows(r).Delete
                End If
            Next r
        End If
    Next i
End With

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top