Sub UserFunctionFind()' === 모듈 시작 ' CodeBy [ User_1 ] , Date :
2009-05-26 On Error ResumeNext Dim Linked AsVariant, Strs As String Dim LnkArr AsVariant
Linked = ActiveWorkbook.LinkSources(xlExcelLinks) '링크 차즌 담 Dim i AsDouble, j AsDouble Dim c As Range, rng As Range Dim Addr As String, AnsAll Dim AnsAdd As New Collection'셀 주소 누적용 If UBound(Linked) = 0 Then MsgBox " 이 시트에는 읍네요", , "그럼 이만..." Exit Sub End If Set rng = Application.InputBox(vbLf & " 가로로 두 열 차지합니다", " 기록할 셀 지정", Type:=8)
ReDim LnkArr(1 To UBound(Linked), 1 To 2) For i = 1 To UBound(Linked)
LnkArr(i, 1) = Linked(i) '배열 1 째에는 전체이름 For j = 1 To Len(LnkArr(i, 1)) '폴더 명과 파일 구분
Strs = Strs & Mid(LnkArr(i, 1), j, 1) If CStr(Mid(LnkArr(i, 1), j, 1)) = "\" Then Strs = "" Next
LnkArr(i, 2) = Strs '배열 2 째에 파일명 Next For i = 1 To UBound(Linked) '일단 닫고 Workbooks(LnkArr(i, 2)).Close Next
i = 0
Strs = Left(Strs, InStr(1, Strs, ".") - 1) With ActiveSheet.Cells'찾기 시작 Set c = .Find(Strs, LookIn:=xlFormulas) If Not c Is Nothing Then
Addr = c.Address
Do
i = i + 1
AnsAdd.Add c.AddressLocal(0, 0), CStr(c.AddressLocal(0, 0)) Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> Addr End If End With For i = 1 To UBound(Linked) Workbooks.Open Filename:=LnkArr(i, 1) Application.Volatile Next
ReDim AnsAll(1 To AnsAdd.Count + 1, 1 To 2)
AnsAll(1, 1) = "셀 주소"
AnsAll(1, 2) = "수식" For i = 1 To AnsAdd.Count
AnsAll(i + 1, 1) = AnsAdd(i)
AnsAll(i + 1, 2) = "'" & Range(AnsAdd(i)).Formula Next
rng.Resize(AnsAdd.Count + 1, 2) = AnsAll End Sub ' ___ 모듈 종료