![]() |
Problem with code. (Compare all cells)
I have the following code to arrange and merge a couple of sheets for me. The problem that I have is with this piticular code my only compares across rows. I need it to check all rows. For example compare row 1 of OOR1 to row 2,3,4,5... of OOR2. Any ideas? Thanks, Met Code: -------------------- Sub Arrange() For a = 1 To 1000 If Sheets("OOR1").Cells(a, "a") = Sheets("OOR2").Cells(a, "a") Then Sheets("OOR1").Cells(a, "H") = Sheets("OOR2").Cells(a, "b") Next a Worksheets("OOR1").Select Dim RngToCopy As Range Dim DestCell As Range Set RngToCopy = Worksheets("OOR1").Range("a2:m10000") Set DestCell = Worksheets("Master").Range("a7") With RngToCopy DestCell.Resize(.Rows.Count, .Columns.Count).Value _ = .Value End With Worksheets("Master").Select Columns("A").SpecialCells(xlCellTypeBlanks).Entire Row.Delete End Sub -------------------- -- Metrazal ------------------------------------------------------------------------ Metrazal's Profile: http://www.excelforum.com/member.php...o&userid=31648 View this thread: http://www.excelforum.com/showthread...hreadid=521038 |
Problem with code. (Compare all cells)
Code: -------------------- Sub Arrange() For a = 1 To 1000 x = Application.Match(Sheets("OOR1").Cells(a, "a"), Sheets("OOR2").Columns("a"), 0) If IsNumeric(x) Then Sheets("OOR1").Cells(a, "H") = Sheets("OOR2").Cells(x, "b") Next a Worksheets("OOR1").Select Dim RngToCopy As Range Dim DestCell As Range Set RngToCopy = Worksheets("OOR1").Range("a2:m10000") Set DestCell = Worksheets("Master").Range("a7") With RngToCopy DestCell.Resize(.Rows.Count, .Columns.Count).Value _ = .Value End With Worksheets("Master").Select Columns("A").SpecialCells(xlCellTypeBlanks).Entire Row.Delete End Sub -------------------- -- Metrazal ------------------------------------------------------------------------ Metrazal's Profile: http://www.excelforum.com/member.php...o&userid=31648 View this thread: http://www.excelforum.com/showthread...hreadid=521038 |
All times are GMT +1. The time now is 05:58 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com