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 (892 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 (892 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 (892 points)
You're welcome. Glad I can offer some help.

Welcome to wellsr Q&A
wellsr Q&A is the VBA and Python programming community that rewards you for learning how to code.

Getting Started
VBA Cheat Sheets (On Sale Now)

Earn free prizes for asking VBA and Python questions and for answering questions asked by others in our community.

Looking for something else? Hire our professional VBA Help, instead.

What makes us different?
Our points system rewards you with a chance for free gifts based on the quality of your questions and answers. All you have to do is post and you could get rewarded, like these members:

ParserMonster $25 Amazon Gift Card
Hightree $10 Amazon Gift Card
Thales1 $10 Amazon Gift Card
runfunke $10 Amazon Gift Card
coolag $10 Amazon Gift Card
Siew Hun $10 Amazon Gift Card

So, why don't you join us? It really is an encouraging way to motivate members in our VBA and Python community.


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