View Full Version : replace macro from list to another sheet

03-14-2011, 02:39 AM
Hi guys, can anyone help me with this problem, I am looking for macro that would replace values in sheet1 with values in list in sheet2(even doesnt have to be different sheets if its easier). Practicaly, i need to replace values (number) in column AD with names from another sheet from column B, that suit numbers from column A. Sheet2 is kind of little database and those ID are unique. In the picture I put another workbook so it could be one sheet by another, for better understanding.
Thanx in advance.

Bob Phillips
03-14-2011, 04:10 AM
Public Sub ProcessData()
Dim Lastrow As Long
Dim i As Long

Application.ScreenUpdating = False

With Worksheets("Sheet1")

Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To Lastrow

With .Cells(i, "AD")

If .Value2 <> "" Then

.Value2 = Application.VLookup(.Value2, Worksheets("Sheet2").Columns("A:B"), 2, False)
End If
End With
Next i
End With

Application.ScreenUpdating = True
End Sub

03-14-2011, 05:11 AM
Thanx man, works exactly as needed.