2017-10-05 3 views
0

현재 코드는 7000 개 이상의 행을 통해 찾습니다.vba 속도 향상 성능

임에 문제가 있습니다.

누구나 성능 향상에 도움을 줄 수 있습니다. 내가 대신 복사/붙여 넣기를 사용하여 통해 반복의, 조사되어 추천 할 것 보호기 VBA

아주 새로운 임

유용성은 할 수 여기에 배열의 사용합니다 그렇다면,

Dim mrow As Long, ARow As Long, i As Long 
Dim AG_Label As String, M_Label As String 
Dim Count As Integer 
Dim AG_sht As Worksheet, M_sht As Worksheet 

    Set AG_sht = Worksheets("AG") 
    Set M_sht = Worksheets("Mappings") 
    Set SNL_sht = Worksheets("SNL") 



    Count = 2 

    ARow = AG_sht.Range("B" & Sheets("AG").Rows.Count).End(xlUp).Row 
     For i = 2 To ARow 
     AG_Label = AG_sht.Cells(i, "N").Value 
     On Error Resume Next 
     mrow = M_sht.Range("C" & Rows.Count).End(xlUp).Row + 1 
     'For j = 2 To mrow 
      'M_Match_1 = Sheets("Mappings").Cells(j, "P").Value 
      M_Label = M_sht.Cells(Count, "C").Value 

      If AG_Label = M_Label And M_sht.Cells(Count, "L").Value = "FRY-9C" Then 
       M_sht.Cells(Count, "J").copy 
       AG_sht.Cells(i, "AM").PasteSpecial Paste:=xlPasteValues, _ 
        Operation:=xlNone, SkipBlanks:=False, Transpose:=False 
      End If 
        If i = ARow Then 
         Count = Count + 1 
         M_Label = Count 
         If mrow <> "" Then 
          i = 2 
         If Count = mrow Then Exit For 
         End If 
        End If 
    Application.CutCopyMode = False 

    Next 

    Call match2 

End Sub 
+2

게시 된 코드 바깥에서'Application.ScreenUpdating = False'를 설정 했습니까? 그렇지 않으면 언제나 시작할 수있는 좋은 곳입니다. – jcarroll

+0

* 현재 코드는 7000 개 이상의 행을 통해 찾고 있습니다. ... 행과 함께 무엇을하고 있습니까? 완전 설명 된 문맥을 제공하십시오. 또한 알 수없는 함수 * match2 *가 있습니다. – Parfait

+0

어째서 충돌을 제거한 다음 성능을 향상시키는 지 확인하십시오. 오류가 발생하는 곳과 오류가 나타나는 곳을 알려주십시오. – jsotola

답변

0

즉각적인 시간을 도와주세요 대상 열에 값을 할당하는 방법. 예 :

If AG_Label = M_Label And M_sht.Cells(Count, "L").Value = "FRY-9C" Then 
      M_sht.Cells(Count, "J").Value = AG_sht.Cells(i, "AM").Value 
     End If 

필자는 복사/붙여 넣기가 많은 비효율을 초래한다고 생각합니다.