Update a cell based on the value in another cell

I have written some VBA for a work worksheet but this one part that should be the simplest is not working and I haven't a clue why. I don't get any error.

I included the bottom macro even though it works perfect just incase something between them is stopping the top one from working.

The code that isn't working is just saying if the data in column A starts with the letter S then column N should say Jessica. Bascially, I have a worksheet with 18k cases. I want to have it list in column N the case worker name based on the first letter of some ones last name which is found in column A.

Sub test()
Dim WB As Workbook
Dim ws1 As Worksheet
    Dim LastRow As Long
    Dim l As Long
  Set WB = Workbooks("Team 3 case listing -test.xlsm")
  Set ws1 = WB.Worksheets("Case List Q-Z")
    LastRow = Range("A" & Rows.Count).End(xlUp).Row
    For l = 2 To LastRow
        If Range("A" & l).Value = "S*" Then
            Range("N" & l).Value = "Jessica"
        End If
    Next l
End Sub


Public Sub update()
Dim WB As Workbook
Dim WB2 As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet, ws3 As Worksheet
Dim ws1LR As Long, ws2LR As Long, ws3LR As Long
Dim i As Long, j As Long, k As Long, LastCol As Long
Dim ws1Rng As Range, acell As Range
Dim ws3Rng As Range, acell2 As Range
Dim ws2Rng As Range
Dim SearchString

Set WB = Workbooks("Team 3 case listing -test.xlsm")
Set WB2 = Workbooks("new data- test.xlsm")
Set ws1 = WB.Worksheets("Case List Q-Z")
Set ws2 = WB2.Worksheets("New Data")
Set ws3 = WB.Worksheets("Workers Comments")

ws1LR = ws1.Range("C" & Rows.Count).End(xlUp).Row
Set ws1Rng = ws1.Range("C2:C" & ws1LR)
ws3LR = ws3.Range("C" & Rows.Count).End(xlUp).Row
Set ws3Rng = ws3.Range("C2:C" & ws3LR)
ws2LR = ws2.Range("C" & Rows.Count).End(xlUp).Row
Set ws2Rng = ws2.Range("C2:C" & ws2LR)

'> Loop through the range in new data wb to match it with the range in case list wb
For i = 1 To ws2LR
    SearchString = ws2.Range("C" & i).Value

    '> Search for the ID on old workbook sheet 1
    Set acell = ws1Rng.Find(What:=SearchString, LookIn:=xlValues, _
    LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False)

If Not acell Is Nothing Then
    '> Append values from new data to case list sheet
        ws1.Cells(acell.Row, 3).Value = ws2.Cells(i, 3).Value
        ws1.Cells(acell.Row, 4).Value = ws2.Cells(i, 4).Value
        ws1.Cells(acell.Row, 5).Value = ws2.Cells(i, 5).Value
        ws1.Cells(acell.Row, 6).Value = ws2.Cells(i, 6).Value
        ws1.Cells(acell.Row, 7).Value = ws2.Cells(i, 7).Value
        ws1.Cells(acell.Row, 8).Value = ws2.Cells(i, 8).Value
        ws1.Cells(acell.Row, 9).Value = ws2.Cells(i, 9).Value
        ws1.Cells(acell.Row, 10).Value = ws2.Cells(i, 10).Value
        ws1.Cells(acell.Row, 11).Value = ws2.Cells(i, 11).Value
        ws1.Cells(acell.Row, 12).Value = ws2.Cells(i, 12).Value
 End If
'> Append values
        For j = 2 To LastCol
            ws1.Cells(acell.Row, j).Value = ws2.Cells(i, j).Value
            Next j
    '> Search for the ID on old workbook sheet 2
    Set acell2 = ws3Rng.Find(What:=SearchString, LookIn:=xlValues, _
    LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False)
 If Not acell2 Is Nothing Then
    '> Append values from new data to worker comments sheet
        ws3.Cells(acell2.Row, 3).Value = ws2.Cells(i, 3).Value
        ws3.Cells(acell2.Row, 4).Value = ws2.Cells(i, 4).Value
        ws3.Cells(acell2.Row, 5).Value = ws2.Cells(i, 5).Value
        ws3.Cells(acell2.Row, 6).Value = ws2.Cells(i, 6).Value
        ws3.Cells(acell2.Row, 7).Value = ws2.Cells(i, 7).Value
        ws3.Cells(acell2.Row, 8).Value = ws2.Cells(i, 8).Value
        ws3.Cells(acell2.Row, 9).Value = ws2.Cells(i, 9).Value
        ws3.Cells(acell2.Row, 10).Value = ws2.Cells(i, 10).Value
        ws3.Cells(acell2.Row, 11).Value = ws2.Cells(i, 11).Value
        ws3.Cells(acell2.Row, 12).Value = ws2.Cells(i, 12).Value

End If
'> Append values
        For k = 2 To LastCol
            ws3.Cells(acell2.Row, k).Value = ws2.Cells(i, k).Value
        Next k
If acell Is Nothing Then
last_row = Cells(Rows.Count, "A").End(xlUp).Row
 ws2.Cells(i, 1).EntireRow.Copy Destination:=ws1.Cells(last_row + 1, "A")
 ws2.Cells(i, 1).Interior.Color = vbYellow
 ws2.Cells(i, 2).Interior.Color = vbYellow
 ws2.Cells(i, 3).Interior.Color = vbYellow
 ws2.Cells(i, 4).Interior.Color = vbYellow
 ws2.Cells(i, 5).Interior.Color = vbYellow
 ws2.Cells(i, 6).Interior.Color = vbYellow
 ws2.Cells(i, 7).Interior.Color = vbYellow
 ws2.Cells(i, 8).Interior.Color = vbYellow
 ws2.Cells(i, 9).Interior.Color = vbYellow
 ws2.Cells(i, 10).Interior.Color = vbYellow
 ws2.Cells(i, 11).Interior.Color = vbYellow
 ws2.Cells(i, 12).Interior.Color = vbYellow
 End If

Next i
End Sub
kira knightSupervisor CSEAAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

yo_beeDirector of Information TechnologyCommented:
What is the value supposed to be if it is not  like "S*"?

You can use a some built in functions to build this.  


Open in new window

kira knightSupervisor CSEAAuthor Commented:
column A can have any value in the alpha. I want to assign 5 workers names to different letters. I am using S* as the example. I don't want to use a formula because the bottom macro adds things to the sheet from another workbook and then I would need to pull the formula down. we are talking thousands of records so I can change the code to

 If Range("A" & l).Value = "S*"
or Range("A" & l).Value="U*"
             Range("N" & l).Value = "Jessica"

I can manipulate it to do the 5 but not sure why what I have isn't working.
yo_beeDirector of Information TechnologyCommented:
So A1 - .... will contain a starting letter associated with a person?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Martin LissOlder than dirtCommented:

 If Range("A" & l).Value = "S*" Then


If Range("A" & l) Like "S*" Then

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kira knightSupervisor CSEAAuthor Commented:
Martin Liss-

Thank you soooo Much- worked perfect!!

Yo- Beez -
Column A could have anything like, smith, santaigo, jones, Jackson, any last name known to man. Martin gave me the answer though.
yo_beeDirector of Information TechnologyCommented:
nice catch
Martin LissOlder than dirtCommented:
You’re welcome and I’m glad I was able to help.

If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange Most Valuable Expert (MVE) 2015, 2017
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
              Experts Exchange Top Expert VBA (current)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.