0 votes
in VBA by Beginner (26 points)
In sheet2 I have client account details and comments.

A column = client code,

B column =client account number

C column=comments..

Same fields i have in sheet1 & I need to add comments in sheet1..using sheet2. With VBA till last row.
by Expert (916 points)
Hello. Can you upload sample of the workbook and some of the desired output?
by Beginner (26 points)

1 Answer

+1 vote
by Expert (916 points)
selected by
Best answer

Try this code

Sub Test()
    Dim a, b, ws As Worksheet, sh As Worksheet, i As Long, j As Long
    Application.ScreenUpdating = False
        Set ws = ThisWorkbook.Worksheets("Client Data")
        Set sh = ThisWorkbook.Worksheets("Output")
        a = ws.Range("A2:C" & ws.Cells(Rows.Count, 1).End(xlUp).Row).Value
        b = sh.Range("A1").CurrentRegion.Value
        For i = 2 To UBound(b)
            For j = 1 To UBound(a)
                If a(j, 1) = b(i, 1) And a(j, 2) = b(i, 2) Then
                    b(i, 3) = a(j, 3)
                End If
            Next j
        Next i
        sh.Range("A1").Resize(UBound(b, 1), UBound(b, 2)).Value = b
    Application.ScreenUpdating = True
End Sub


by Beginner (26 points)
Perfect it's working fine !
Thank you so much ! :)
by Expert (916 points)
You're welcome. Glad I can offer some help.

Welcome to wellsr Q&A
Ask any questions you have about VBA and Python and our community will help answer them. wellsr Q&A is the standalone question and answer platform for wellsr.com. If you have a question about one of our specific tutorials, please include a link back to the tutorial.

Getting Started
VBA Cheat Sheets (On Sale Now)

Looking for something else? Hire our team directly through ourVBA Help page, instead.

For more programming tips visit the VBA Tutorials Blog and the Python Tutorials Blog.