Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hello All-
I have a code that pulls data from another worksheet into the worksheet that i am working on, but the only problem is that the code pulls exactly 100 lines of data from the other worksheet. I need to modify the code to where it'll pull the last row of data whether it's 5 lines , 100 lines or 500 lines. Can anyone help? The code is written below 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 4 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("A1").Address(, , xlR1C1) ' Execute an XLM macro GetValue = ExecuteExcel4Macro(arg) End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to import data from another worksheet & leave duplicate out? | Excel Discussion (Misc queries) | |||
CAN I IMPORT DATA FROM A CLOSED FILE TO A NEW WORKSHEET | Excel Discussion (Misc queries) | |||
Import external data in protected worksheet | New Users to Excel | |||
Import data from another worksheet | Excel Discussion (Misc queries) | |||
How do I selectively import data from another Excel worksheet? | Excel Discussion (Misc queries) |