Problem with code. (Compare all cells)

  • Thread starter Thread starter Metrazal
  • Start date Start date
M

Metrazal

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).EntireRow.Delete
End Sub
 
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).EntireRow.Delete
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top