VBA to automatically add text to a cell based on another worksheet

kwooden0626

New Member
Joined
Oct 15, 2016
Messages
20
:confused:
Hello,

I'm not familiar with writing VBA code and I want to know if anyone can assist me with writing a code that will automatically add "Yes" to a cell if an employee's name is listed on another worksheet within the same workbook.

I have a worksheet (Sheet 1) that lists all employees for a particular company and another worksheet (Sheet 2) that has names of employees who are qualified as technicians. I receive an updated list weekly for all qualified technicians so I need the VBA to compare both worksheets and enter "Yes" in the Column for "Qualified Technician." There are over 200 names on the Employees worksheet and over 500 names on the Qualified Technicians worksheet so it takes quite sometime to manually compare the two. Also, not all employees on the Technicians worksheet belong to the company that I need to update and the name structure is different as well. My worksheet list the name in three separate columns (Last, First, M.I.); the technicians worksheet is pulled from another departments database and list the name in one column (Last, First, M.I.).

I've created sample worksheets to show the structure of both worksheets. I will appreciate any assistance anyone can provide.

Sheet 1



Sheet 2
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

NdNoviceHlp

Well-known Member
Joined
Nov 9, 2002
Messages
2,484
If U maintain the exact format as shown for both sheets, this would work in Sheet1!E2 (adjust sheet2 range to suit). You can copy the formula down "E" but will have to adjust the sheet2 range for each copied cells. HTH. Dave
Code:
=IF(COUNTIF(Sheet2!A2:A10,A2 & ", " & B2 & " " & C2)>0,"yes","no")
 

kwooden0626

New Member
Joined
Oct 15, 2016
Messages
20
[h=1]NdNoviceHlp,[/h]
Thank you so much. It works exactly the way I needed it to and I can't thank you enough. This code will make my job so much easier now that I don't have to manually scan the two worksheets.
 

Watch MrExcel Video

Forum statistics

Threads
1,096,322
Messages
5,449,712
Members
405,575
Latest member
Masimo85

This Week's Hot Topics

Top