Add a name based on a number
Tested and debugged:
Option Explicit
Sub Do_Eds_Stuff()
Dim ws1, ws2 As Worksheet
Dim MyRange, FoundCell As Range
Dim i, x As Variant
Dim ElastRow, Alastrow As Long
Set ws1 = ActiveWorkbook.Worksheets(1)
Set ws2 = ActiveWorkbook.Worksheets(2)
Alastrow = ws1.Cells(ws1.Cells.Rows.Count, "A").End(xlUp).Row
ElastRow = ws2.Cells(ws2.Cells.Rows.Count, "E").End(xlUp).Row
Set MyRange = ws2.Range("E1:E" & ElastRow)
x = 1
For Each i In MyRange
ws1.Range("A1:A" & Alastrow).Find (i)
Set FoundCell = ws1.Range("A1:A" & Alastrow).Find(i)
If FoundCell Is Nothing Then
Exit Sub
ElseIf FoundCell = i Then
ws2.Cells(x, 4).Value = FoundCell.Offset(0, 1).Value
End If
x = x + 1
Next
End Sub
"ed.cabrera" wrote:
I might be pressing my luck here ....but (I already got one really
good answer off here today ; )
Ok here's what I'm trying to figure out now:
Spreadsheet 1 contains the client's name in column A and their
employee number in column B
Spreadsheet 2 contains raw data that only lists the client's employee
number in column E.
Is there a simple (or macro) solution that can run in Spreadsheet 2
and compare what's in column E to what's in column B in Spreadsheet 1;
and then enter the client's name in column D of Spreadsheet 2?
Thanks for the help, everyone!
|