View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
hirandesilva hirandesilva is offline
external usenet poster
 
Posts: 5
Default Macro to look up values in 2 different columns

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