Hi all,
I want to vlookup from an closed workbook. i have the below code which pulls up the particular column data from an closed book.
When i apply the formula(=VLOOKUP(B18,'C:\My Documents\Temp\[Demo.xls]Sheet1'!$A$1:$B$10,2,FALSE). the file size gets heavy. Is there an better way around please advise.
I want to vlookup from an closed workbook. i have the below code which pulls up the particular column data from an closed book.
When i apply the formula(=VLOOKUP(B18,'C:\My Documents\Temp\[Demo.xls]Sheet1'!$A$1:$B$10,2,FALSE). the file size gets heavy. Is there an better way around please advise.
Code:
[TABLE="width: 64"]
<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"]Sub copyColData()[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Dim lastRow As Long[/TD]
[/TR]
[TR]
[TD]Dim myApp As Excel.Application[/TD]
[/TR]
[TR]
[TD]Dim wkBk As Workbook[/TD]
[/TR]
[TR]
[TD]Dim wkSht As Object[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Set myApp = CreateObject("Excel.Application")[/TD]
[/TR]
[TR]
[TD]Set wkBk = myApp.Workbooks.Open("C:\Users\Home\Downloads\Movies201(3).xlsm")[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]lastRow = wkBk.Sheets(1).Range("D" & Rows.Count).End(xlUp).Row[/TD]
[/TR]
[TR]
[TD]wkBk.Sheets(1).Range("D1:D" & lastRow).Copy[/TD]
[/TR]
[TR]
[TD]myApp.DisplayAlerts = False[/TD]
[/TR]
[TR]
[TD]wkBk.Close[/TD]
[/TR]
[TR]
[TD]myApp.Quit[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Set wkBk = Nothing[/TD]
[/TR]
[TR]
[TD]Set myApp = Nothing[/TD]
[/TR]
[TR]
[TD]Set wkBk = ActiveWorkbook[/TD]
[/TR]
[TR]
[TD]Set wkSht = wkBk.Sheets("Sheet1")[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]wkSht.Activate[/TD]
[/TR]
[TR]
[TD]Range("A1").Select[/TD]
[/TR]
[TR]
[TD]wkSht.Paste[/TD]
[/TR]
[TR]
[TD]Exit Sub[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]End Sub[/TD]
[/TR]
</tbody>[/TABLE]