• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA codes for Vlookup

Bhashkar

New Member
Hi,

I am extremely new to macro and I am confused with a simple task that requires me to populate execution date for a set of identifiers. Please find attached the workbook for your reference.

I want the "Execution date" (Column D, Data sheet) to be pasted in Column B of Target sheet, next to their respective identifiers. The data is to be populated from Data sheet that contains the identifiers (Column I) and execution dates.

I hope I have explained it right. The codes I am using is not working. Please see the below codes for your reference, although I know my logic is completely wrong:
Code:
Sub ADDCLM()
On Error Resume Next
Dim CD_Row As Long
Dim CD_Clm As Long
Table1 = Sheet1.Range("A2:A9133")
Table2 = Sheet2.Range("I2:I11523")
CD_Row = Sheet1.Range("B2").Row
CD_Clm = Sheet1.Range("B2").Column
For Each cl In Table1
Sheet1.Cells(CD_Row, CD_Clm) = Application.WorksheetFunction.VLookup(cl, Table2, 4, False)
CD_Row = CD_Row + 1
Next cl
MsgBox "Completion date done"
End Sub
I would appreciate if you could help me with this. Thanks!
 

Attachments

  • check.xlsx
    663.1 KB · Views: 6
Last edited by a moderator:
Hi !

Data are not well organized for VLookup !

Formula in cell B2 :

=INDEX('Data sheet'!$D$1:$D$11523,MATCH(A2,'Data sheet'!$I$1:$I$11523,0))

Copy down …
 
Back
Top