I have a sheet that has a List box when that is selected codes appear , if a code is selected excel copies the data from a worksheet (with the same code ) into a quotation sheet.
If I make a change a select another code in the same list box I need excel to go and find the old data and delete it in the Quotation sheet.
Public Sub delete_selected_rows() Dim rng1 As Range, rng2 As Range, rngToDel As Range, c As Range Dim lastRow As Long
With Worksheets("Q")
lastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
Set rng1 = .Range("B1:B" & lastRow)
End With
Set rng2 = Worksheets("SO").Range("D35")
For Each c In rng1
If Not IsError(Application.Match(c.Value, rng2, 0)) Then
'if value from rng1 is found in rng2 then remember this cell for deleting
If rngToDel Is Nothing Then
Set rngToDel = c
Else
Set rngToDel = Union(rngToDel, c)
End If
End If
Next c
If Not rngToDel Is Nothing Then rngToDel.CurrentRegion.Delete
End Sub
How can I get CurrentRegion to count an extra 30 rows the delete