Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I compare cells and if FALSE compare to next cell in EXCEL | Excel Worksheet Functions | |||
Help with VB code to compare two columns | Excel Programming | |||
Error Code when compare cells in excel macro | Excel Programming | |||
Compare tabs using Double Lookup, in VB code | Excel Programming | |||
Compare tabs using Double Lookup, in VB code | Excel Programming |