2016-09-20 2 views
0

파일 집합을 열고, 숨김을 표시하고 특정 워크 시트로 이동하고, 다른 통합 문서의 범위와 붙여 넣기를 복사하는 길이 코드가 있습니다.update links prompt issue

코드가 이러한 파일을 열 때마다 링크를 업데이트하는 팝업 메시지가 나타납니다. updatelinks = 0으로 해결할 수 있다는 것을 알고 있지만 내 코드에이 코드를 어디에 포함시켜야하는지 알고 싶었습니다.

또한 코드를 실행하는 데 시간이 걸리므로 빠른 실행을 위해 수정이 필요합니다.

Sub mergeallinputworkbooks() 
    Dim wkbDest As Workbook 
    Dim wksDest As Worksheet 
    Dim wkbSource As Workbook 
    Dim wksSource As Worksheet 
    Dim MyPath As String 
    Dim MyFile As String 
    Dim FolderName As String 
    Dim oCell As Range   
    Application.ScreenUpdating = False 
    Application.DisplayAlerts = False 
    Application.EnableEvents = False 
    Set wkbDest = ThisWorkbook 
    Set wksDest = wkbDest.Worksheets("Master Data") 
    With Application.FileDialog(msoFileDialogFolderPicker) 
     .AllowMultiSelect = False 
     .Show 
     On Error Resume Next 
     FolderName = .SelectedItems(1) 
     Err.Clear 
     On Error GoTo 0 
    End With 
    MyPath = FolderName 
    If Right(MyPath, 1) <> "\" Then MyPath = MyPath & "\" 
    MyFile = Dir(MyPath & "*.xls") 
    Do While Len(MyFile) > 0 
     Set wkbSource = Workbooks.Open(MyPath & MyFile) 
     Set wksSource = wkbSource.Worksheets("Scoring DB") 
     ActiveWorkbook.Unprotect ("pyroo123") 
     Sheets("Scoring DB").Visible = True 
     Sheets("Scoring DB").Select 
     Range("A4:W4").Copy 
     Windows("Performance Dashboard.xlsm").Activate 
     With Sheets("Master Data").Range("$A:$A") 
     With Sheets("Master Data") 
Set oCell = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0) 
End With 
oCell.Select 
     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False 
     Application.CutCopyMode = False 
     Windows("Performance Dashboard.xlsm").Activate 
    End With 
     wkbSource.Close savechanges:=False 
     MyFile = Dir 
    Loop 
    Application.ScreenUpdating = True 
    Application.DisplayAlerts = True 
    Application.EnableEvents = True 
End Sub 

답변

0

링크 문제인 경우 have a look at this post입니다. 링크 업데이트를 사용하는 방법과 위치를 알려주는 충분한 정보가 있어야합니다.

이제 코드를 제안 :
이 코드의 성능을 향상시키기 위해, 나는 어디에 필요하지 워크 시트와 상호 작용하지 제안합니다. 오히려 '복사 및 과거'가 아닌 배열의 범위를 지정 :

arrMyRange = Worksheets("SourceWorksheet").Range("A4:W4") 

이 배열을 생성합니다. 이제 위치에 배열을 할당 : 필요한 경우

Worksheets("DestinationWorksheet").Range("A1").Resize(UBound(arrMyRange, 1), UBound(arrMyRange, 2)).Value = arrMyRange 

A1 동적으로 변경 될 수 있습니다.

+0

어디에 포함되어야하는지 알려주십시오. 가능한 경우 코드를 수정하십시오. –