LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Macro to match 2 column values in different sheets

Hi,

I need a macro which compares the values in colA and colC of sheet 1
to column D and column E of sheet 2, if both the value match, then it
copies the contents from sheet2 col F,G and H into sheet1 colC,D and
F.


I tried the code below but I got an error message saying:Subscript out
of range
Please advise if any modifications required in the following code:
Thanks



Sub CompareThis()

For iRow = 1 to 1000


If Sheets("Sheet1").cells(iRow, 1).Value = Sheets("Sheet2").cells
(iRow, 4).Value And _
Sheets("Sheet1").cells(iRow, 3).Value = Sheets("Sheet2").cells(iRow,
5).Value Then


Sheets("Sheet1").cells(iRow, 3).Value = Sheets("Sheet2").cells(iRow,
6).Value
Sheets("Sheet1").cells(iRow, 4).Value = Sheets("Sheet2").cells(iRow,
7).Value
Sheets("Sheet1").cells(iRow, 5).Value = Sheets("Sheet2").cells(iRow,
8).Value


End IF



Next iRow
End Sub
 
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
HELP: Match values from different sheets and populate a column Sam Excel Programming 3 October 16th 09 12:29 PM
Copy cell values if cells match on two diff sheets dan Excel Programming 0 June 23rd 06 02:00 PM
Vlookup? to match column in two sheets researcy Excel Discussion (Misc queries) 2 February 27th 06 05:58 PM
How can I match up values from 2 sheets and info in adjoining cell naclu Excel Discussion (Misc queries) 4 February 3rd 06 10:50 PM
Sum values in multiple sheets using Lookup to find a text match CheriT63 Excel Worksheet Functions 7 December 4th 05 02:33 AM


All times are GMT +1. The time now is 02:11 PM.

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"