Cascaded String VBA Issues

I am trying to assign each of the IDs that you see in columns E and F ws4here ...

enter image description here

... to the corresponding identifier on mine wsOutputin columns K and L respectively.

enter image description here

My code passes without error, but nothing happens. This is one of my first projects, so I apologize if this is a straightforward question.

I also consulted on the Internet and found:

However, I was not able to get them to work.

Any help is much appreciated!

'Previous Code
'wsOutput -> Filter Sheet - Worksheet (TARGET) ; ws4 = Search Skills - Worksheet (SOURCE)
Dim separator As String, PreviousResultCG As String, NewResultCG As String, PreviousResultCategory As String, NewResultCategory As String

If separator = "" Then separator = " , "

'lRowInput = ws4.Range("A" & Rows.Count).End(xlUp).row - from above
lRowOutput = wsOutput.Range("A4:A" & Rows.Count).End(xlDown).row


With ws4

    'For each ID on the Source-Worksheet
    For Each ID In .Range("A2:A" & lRowInput)

        'Find the respective ID on Target-Worksheet
        Set FindID = wsOutput.Range("A4:A" & lRowOutput).Find(what:=ID, LookIn:=xlValues, lookat:=xlWhole)

        'Get all CG ID for the supplier and add them to previously found ID of that supplier
        If FindID = ID Then

            PreviousResultCG = wsOutput.Range("K" & FindID.row).value

            NewResultCG = PreviousResultCG & separator & .Range("E" & ID.row)

            wsOutput.Range("K" & ID.row).value = NewResultCG


            PreviousResultCategory = wsOutput.Range("L" & FindID.row).value

            NewResultCategory = PreviousResultCategory & separator & .Range("F" & ID.row)

            wsOutput.Range("L" & FindID.row).value = NewResultCategory

        End If

    Next ID

End With
+4
1

"source" , , "target". , .

.

Sub look_values()

Dim id, source_id As Range
Dim data_row_num, id_row_num As Long
Dim source_sheet, target_sheet As Worksheet
Dim cg, cat As String

Set source_sheet = ThisWorkbook.Sheets("source")
Set target_sheet = ThisWorkbook.Sheets("target")
Set id = target_sheet.Range("A2")

Do Until id.Value = ""

    source_sheet.Activate
    Range("A1").Activate
    Set source_id = Range("A:A").Find(what:=id.Value, LookIn:=xlValues, lookat:=xlWhole)
    On Error Resume Next
    cg = Cells(source_id.Row, 5).Value
    On Error Resume Next
    cat = Cells(source_id.Row, 6).Value
    target_sheet.Activate
    Cells(id.Row, 11).Value = cg
    Cells(id.Row, 12).Value = cat
    Set id = id.Offset(1, 0)
Loop

End Sub

, ID . . , .

+1

Source: https://habr.com/ru/post/1656182/


All Articles