marreco
02-11-2013, 03:21 AM
Hi.
the code below, demand data "Sheet1" with discretion in "Sheet2"
to find it overrides the value of "Sheet2" and put in "Sheet1"
Option Explicit
Sub Macro1()
Dim rngCell As Range
Dim lngMatchRowNum As Long
Application.ScreenUpdating = False
With Sheets("Sheet1")
For Each rngCell In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
If (IsError(Evaluate("VLOOKUP(" & Sheets("Sheet1").Range(rngCell.Address(False, False)) & ",Sheet2!A:A,1,FALSE)"))) = False Then
lngMatchRowNum = Evaluate("MATCH(" & Sheets("Sheet1").Range(rngCell.Address(False, False)) & ",Sheet2!A:A,0)")
.Range("B" & rngCell.Row & ":F" & rngCell.Row).Value = Sheets("Sheet2").Range("B" & lngMatchRowNum & ":F" & lngMatchRowNum).Value
End If
Next rngCell
End With
Application.ScreenUpdating = True
MsgBox "Todos os registros aplicáveis já foram atualizados."
End Sub
Now what I need is:
If the value of "Sheet2" not found in "Sheet2" so that the value
the "Sheet2" is inderido the next empty line (below) of "Sheet1"
the code below, demand data "Sheet1" with discretion in "Sheet2"
to find it overrides the value of "Sheet2" and put in "Sheet1"
Option Explicit
Sub Macro1()
Dim rngCell As Range
Dim lngMatchRowNum As Long
Application.ScreenUpdating = False
With Sheets("Sheet1")
For Each rngCell In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
If (IsError(Evaluate("VLOOKUP(" & Sheets("Sheet1").Range(rngCell.Address(False, False)) & ",Sheet2!A:A,1,FALSE)"))) = False Then
lngMatchRowNum = Evaluate("MATCH(" & Sheets("Sheet1").Range(rngCell.Address(False, False)) & ",Sheet2!A:A,0)")
.Range("B" & rngCell.Row & ":F" & rngCell.Row).Value = Sheets("Sheet2").Range("B" & lngMatchRowNum & ":F" & lngMatchRowNum).Value
End If
Next rngCell
End With
Application.ScreenUpdating = True
MsgBox "Todos os registros aplicáveis já foram atualizados."
End Sub
Now what I need is:
If the value of "Sheet2" not found in "Sheet2" so that the value
the "Sheet2" is inderido the next empty line (below) of "Sheet1"