Hi Team,
Below is my vlookup. this code is for single worksheet it works. I want to run this code for sheets {1,2,4,6} only and in column B1. if vlook up result give exact match it should display the result :=> For match "Old trades", else "New trades".
Colomn for vlookup is fix. (b:b). plz help.
Sub Test()
Dim lr As Long
Dim i As Integer
Dim wbk As Workbook
Set wbk = Workbooks.Open("E:\Software\For v lookup.xlsm")
wbk.Worksheets(1).Activate
On Error GoTo Pranay:
lr = Cells(Rows.Count, 1).End(xlUp).Row - 1
i = 1
For i = 1 To lr
Sheets(1).Range("b" & i + 1).Value = WorksheetFunction.VLookup(Sheets(1).Range("a" & i + 1).Value, ThisWorkbook.Sheets(3).Range("c:g"), 2, 0)
Next
Exit Sub
Pranay:
Sheets(1).Range("b" & i + 1).Value = " New Trade"
Resume Next
End Sub
Regards,
Mallesh
Below is my vlookup. this code is for single worksheet it works. I want to run this code for sheets {1,2,4,6} only and in column B1. if vlook up result give exact match it should display the result :=> For match "Old trades", else "New trades".
Colomn for vlookup is fix. (b:b). plz help.
Sub Test()
Dim lr As Long
Dim i As Integer
Dim wbk As Workbook
Set wbk = Workbooks.Open("E:\Software\For v lookup.xlsm")
wbk.Worksheets(1).Activate
On Error GoTo Pranay:
lr = Cells(Rows.Count, 1).End(xlUp).Row - 1
i = 1
For i = 1 To lr
Sheets(1).Range("b" & i + 1).Value = WorksheetFunction.VLookup(Sheets(1).Range("a" & i + 1).Value, ThisWorkbook.Sheets(3).Range("c:g"), 2, 0)
Next
Exit Sub
Pranay:
Sheets(1).Range("b" & i + 1).Value = " New Trade"
Resume Next
End Sub
Regards,
Mallesh