Copy rows that matches cell value

  • Thread starter Thread starter Kashyap
  • Start date Start date
K

Kashyap

Hi,

I need to copy rows where value of Col L matches with cell A1 and paste in a
different sheet.
 
Hi,

Right click the sheet tab with your source data and view code and paste the
code below in. It copies to sheet2 so change to suit

Sub delete_Me()
Dim copyrange As Range
lastrow = Cells(Cells.Rows.Count, "L").End(xlUp).Row
Set MyRange = Range("L2:L" & lastrow)
For Each c In MyRange
If c = Range("A1").Value Then
If copyrange Is Nothing Then
Set copyrange = c.EntireRow
Else
Set copyrange = Union(copyrange, c.EntireRow)
End If
End If
Next
If Not copyrange Is Nothing Then
copyrange.Copy Destination:=Sheets("Sheet2").Range("A1")
End If
End Sub

Nike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top