Jiyu has attended:
Excel for Scientists day 3 course
Excel for Scientists day 2 course
Excel for Scientists Day 1 course
Excel VBA Intermediate course
VBA
Can I use VBA to retrieve data from other workbooks without needing to open those workbooks?
RE: VBA
Hi Jiyu,
Thank you for the question and I hope you are fine.
Below you can find an example. In my example the code will open a workbook, get the data, and close the workbook we have retrieved the data from. I hope the example makes sense.
Sub Example1()
Dim objWorkbook As Workbook
Dim i As Integer
'open the workbook with data
Set objWorkbook = Workbooks.Open( _
"D:StuffBusinessTempData.xlsx")
'read the data from the first columns
For i = 1 To 9
Cells(i, 1) = _
objWorkbook.Worksheets("Sheet1").Cells(i + 1, 1)
Next i
'close the workbook
objWorkbook.Close
End Sub
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector