Results 1 to 4 of 4

Thread: VBA to automatically add text to a cell based on another worksheet
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Oct 2016
    Posts
    20
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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


    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

  2. #2
    Board Regular NdNoviceHlp's Avatar
    Join Date
    Nov 2002
    Location
    Manitoba Canada
    Posts
    2,256
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    2 Thread(s)

    Default Re: VBA to automatically add text to a cell based on another worksheet

    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")

  3. #3
    New Member
    Join Date
    Oct 2016
    Posts
    20
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA to automatically add text to a cell based on another worksheet

    NdNoviceHlp,

    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.

  4. #4
    Board Regular NdNoviceHlp's Avatar
    Join Date
    Nov 2002
    Location
    Manitoba Canada
    Posts
    2,256
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    2 Thread(s)

    Default Re: VBA to automatically add text to a cell based on another worksheet

    You are welcome. Thanks for posting your outcome. Dave

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •