Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Default Match Copy/Paste Macro almost there

I found the following code for a macro that almost does everything I need it to. Right now what the code does is it find a match and pastes the value in the cell right next to it. But rather then just pasting one value I'd like it to paste the entire row next the the match on Sheet1.

Example:

Sheet 1: When it finds a match in "Column A" which is Sales Order to a match on Sheet 2 "Column A", it would then paste the row from Sheet 2 next to the match on Sheet 1

Option Explicit
Sub CopyIDData()
Dim rng As Range
Dim rng1 As Range
Dim cell As Range
Dim res As Variant

With Worksheets("sheet1")
Set rng = .Range("A1", .Cells(.Rows.Count, "A").End(xlUp))
End With

With Worksheets("Sheet2")
Set rng1 = .Range("A1", .Cells(.Rows.Count, "A").End(xlUp))
End With

For Each cell In rng.Cells
If Trim(cell.Value) = "" Then
'skip it
Else
res = Application.Match(cell, rng1, 0)
If Not IsError(res) Then
rng1(res, 2).Resize(1, 1).Copy Destination:=cell.Offset(0, 1)
End If
End If
Next cell
End Sub

Thanks

James
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
match, copy, paste, & color Stephen[_24_] Excel Programming 2 April 2nd 08 03:28 PM
Match , copy paste (using find?) Carlos Excel Programming 3 March 12th 08 10:33 AM
Compare col and match then copy and paste saman110 via OfficeKB.com Excel Discussion (Misc queries) 2 February 21st 08 12:28 AM
Copy Cell, Paste based on a match. Pete Excel Programming 2 July 23rd 07 07:20 PM
help with match, copy, paste please Mona Excel Programming 6 July 20th 06 02:35 AM


All times are GMT +1. The time now is 03:33 PM.

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

About Us

"It's about Microsoft Excel"