2014-02-10 3 views
1

다음 매크로를 사용하여 데이터베이스로 가져 오기 전에 데이터를 마사지합니다. 기준은 76 또는 77 열에는 아무 것도 없으며 82 열에는 "99"가 있어야한다는 것입니다. 위의 모든 기준이 충족되면 6 열에는 "반품 됨"이라고 표시되어야합니다. 인수가 잘못되거나 속성 할당 오류가 잘못되었습니다.속성 할당이 잘못 되었습니까?

Sub V_11() 
    Dim mySheet As Worksheet, myBook As Workbook 'Define your workbooks and worksheets as variables 
    Set myBook = Excel.ActiveWorkbook 
    Set mySheet = myBook.Sheets("Sheet1") 
    Dim i As Integer, j As Integer 'Define a couple integer variables for counting 
    j = 2 
    For i = 2 To mySheet.UsedRange.Rows.Count 
     If IsEmpty(mySheet.Cells(i, 76, 77).Value) And mySheet.Cells(i, 82) = "99" Then 
      mySheet.Cells(i, 6).Value = "Returned" ' . . . place the text "N/A" into the cell in row "j" in Sheet2. 
     End If 
    Next 
End Sub 

답변

3

mySheet.Cells(i, 76, 77).Value은 유효하지 않습니다.

당신은 문

If IsEmpty(mySheet.Cells(i, 76)) And IsEmpty(mySheet.Cells(i, 77)) And mySheet.Cells(i, 82) = "99" Then 
이 는 1+ 좋은 캐치 :
+1

이 경우에 그것을 분리 할 필요가! 정말 고맙습니다! –

+1

이 완벽하게 작동 – autumntiger

관련 문제