Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Copy rows that matches cell value

Hi,

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Copy rows that matches cell value

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

"Kashyap" wrote:

Hi,

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Copy rows that matches cell value

Thanks Nike..



Would you please help with another post of mine...?

Macro to take cell ref of the object


http://www.microsoft.com/communities...9-9a8428960f8e




"Mike H" wrote:

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

"Kashyap" wrote:

Hi,

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get last 6 rows in list where 1 cell matches certain criteria Struggling in Sheffield[_2_] New Users to Excel 2 March 13th 09 12:54 AM
If cell 'a' matches cell 'b' then copy cell 'd' to cell 'e' Marie Excel Programming 6 May 23rd 08 07:46 PM
copy if data matches [email protected] Excel Worksheet Functions 3 April 17th 08 11:47 PM
Delete rows if value matches Rob Excel Programming 5 March 13th 08 11:49 AM
if cell value matches then copy another cell billbeecham[_10_] Excel Programming 11 November 29th 05 08:46 AM


All times are GMT +1. The time now is 07:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"