Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hello all-
I have an opened workbook that needs to pull data from a closed workbook. Does anyone have a macro that can pull data from the closed workbook and import it into the opened workbook? I don't know how many rows of data there are, but there are always 4 columns. I am currently using the code below, but it only pulls 100 rows of data. I need a macro that will pull tdata from the last used row. Can any tweak the code or maybe have a better one? Thanks Sub Retrieve_Info() P = "C:\Documents and Settings\David Truong\Desktop" f = "Book2.xlsm" s = "Sheet1" Application.ScreenUpdating = False For r = 1 To 100 For c = 1 To 3 a = Cells(r, c).Address Cells(r, c) = GetValue(P, f, s, a) Next c Next r Application.ScreenUpdating = True End Sub Private Function GetValue(path, file, sheet, ref) ' Retrieves a value from a closed workbook Dim arg As String ' Make sure the file exists If Right(path, 1) < "\" Then path = path & "\" If Dir(path & file) = "" Then Exit Function End If ' Create the argument arg = "'" & path & "[" & file & "]" & sheet & "'!" & _ Range(ref).Range("a2").Address(, , xlR1C1) ' Execute an XLM macro GetValue = ExecuteExcel4Macro(arg) End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using Closed Workbook as Data Book | Excel Discussion (Misc queries) | |||
CAN I IMPORT DATA FROM A CLOSED FILE TO A NEW WORKSHEET | Excel Discussion (Misc queries) | |||
How do I import data from a closed Excel Spreadsheet? | Excel Discussion (Misc queries) | |||
Data Validation From Closed WorkBook | Excel Discussion (Misc queries) | |||
How to extract data from a wooksheet in a closed workbook | Excel Worksheet Functions |