http://kin.naver.com/qna/detail.nhn?d1id=1&dirId=102020101&docId=71906817&qb=7JeR7IWA7YyM7J28IOyXtOyngCDslYrqs6Ag7JeF642w7J207Yq4&enc=utf8&section=kin&rank=2&search_sort=0&spq=0

안녕하세요~

excell4.0메크로를 사용하시면 될듯합니다.

 

불러올 파일과 기록할 파일이 같은 폴더에 있다고 가정합니다.

 

불러올 파일 이름이 XLM_1.XLS 일때

기록할 파일의 B2:B4셀에

XLM_1.XLS 파일의 Sheet1 시트의 A1:A3셀의 데이타를 불러오는 경우의 코드입니다.

참조하시고 좋은 결과 있으시길~~~

 

Option Explicit

 

Sub Call_Data()
Dim strPath As String, strFile As String, strSht As String, strCell As String
Dim i As Integer

 

strPath = ThisWorkbook.Path & "\"
strFile = "XLM_1.xls"
strSht = "Sheet1"


For i = 0 To 2
    strCell = Range("a1").Offset(i, 0).Address
    Range("b2").Offset(i, 0) = Get_Data(strPath, strFile, strSht, strCell)
Next

End Sub

 

 

 

Function Get_Data(Path, File, Sht, Cell)

Dim strD As String
   

strD = "'" & Path & "[" & File & "]" & Sht & "'!" & Range(Cell).Address(, , xlR1C1)
Get_Data = ExecuteExcel4Macro(strD)

End Function

 

반응형

+ Recent posts