Dear Friends ,
i am struggling with Vloook as i am new to VBA , i am trying to get the values with the help of Vlook up once workbook gets opened unfortunately not getting any values , its blank not sure what is wrong with the code
i am running a vlook in worksheet Refund Payable report and in column R from another workbook which is Insurance plan in Coumn B to C
here is the normal vlook up
=VLOOKUP(H2,'[Insurance Plans.xlsb]Ins Plan Number'!$B1:$C20000,2,0)
i had post this query on another forum too however i was not getting any resolution , re-posting it here , if meanwhile i got response will keep you posted , Shall anyone please review and let me know where i am wrong .
Your help is highly appreicated
i am struggling with Vloook as i am new to VBA , i am trying to get the values with the help of Vlook up once workbook gets opened unfortunately not getting any values , its blank not sure what is wrong with the code
i am running a vlook in worksheet Refund Payable report and in column R from another workbook which is Insurance plan in Coumn B to C
here is the normal vlook up
=VLOOKUP(H2,'[Insurance Plans.xlsb]Ins Plan Number'!$B1:$C20000,2,0)
Code:
Sub Open_Workbooks()
Dim wb As Workbook
Dim lastrow As Long, i As Long
Dim rw As Long, x As Range
Dim extwbk As Workbook, twb As Workbook
Set twb = ThisWorkbook
Set extwbk = Workbooks.Open("Y:\Sachin Gupta\Cannon\Insurance Plans.xlsb")
Set x = extwbk.Worksheets("Ins Plan Number").Range("B1:C20000")
With twb.Sheets("Refund Payable report")
For rw = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
.Cells(rw, 18) = Application.VLookup(.Cells(rw, 18).Value2, x, 3, False)
Next rw
End With
extwbk.Close savechanges:=False
i had post this query on another forum too however i was not getting any resolution , re-posting it here , if meanwhile i got response will keep you posted , Shall anyone please review and let me know where i am wrong .
Your help is highly appreicated