Employee name replacement (macro)

javijuan

New Member
Joined
Feb 3, 2016
Messages
6
Hello, I need a macro (in a module) that can replace the employee name with the corresponding employee ID from a different sheet called "roster".
I tried to attach a file as an example but could not figure out how to do it.
I would greatly appreciate any help.

PS: I am not good at writing codes, but I can understand them and edit them once I see a working code.

Roster sheet - b3 (id) - c20 (names)
Emp ID
Name
269386
Cam, I
263063
Cas, K
219903
Hen, A
244341
Joh, A
248837
Mir, J
293500
Nav, A
271742
Rod, M
276673
San, E
289349
San, Jah
280683
Vel, R

<tbody>
</tbody>


On the other sheets I have a table with their production, adherence to schedule, productivity and so on.. every day I have to send a Daily stats.. but for privacy issues, we change their names with the employee ID so, people do not know what their peers are doing right or wrong.. We use 3 or 4 different tables, so their name are not always on the same cells. I need a macro that looks for a match of their names compared to the roster sheet (that sheet does not change) and replace the names with the ID.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Rich (BB code):
Dim ws, ds As Object
Set ws = activesheet
Set ds = Worksheets("Roster")
'I put names in column A, ID in column B, so offset is 1 cell to right
For Each cll In ws.Range("a1:a" & Cells(Rows.Count, 1).End(xlUp).Row)
    For Each cll2 In ds.Range("a1:a" & Cells(Rows.Count, 1).End(xlUp).Row)
        If cll.Value = cll2.Value Then
            cll.Value = cll2.Offset(0, 1).Value
        End If
        Next cll2
Next cll
 
Upvote 0

Forum statistics

Threads
1,216,581
Messages
6,131,544
Members
449,654
Latest member
andz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top