2014-03-26 4 views
0

나는 실행 유형의 오류 (13)가 계속 - 형식이 일치하지실행 형 오류 13 - 형식이 일치하지

에서 다음 줄 :

Set cel = wshS.Columns(1).Find(What:="EMEA\" + wshT.Cells(r, 10 + cCtr).Value, _ 
    LookAt:=xlWhole, MatchCase:=False) 

당신이 원인이 될 수있는 것을 알고 계십니까? 무슨 뜻이에요?

아래

전체 코드 :

Sub VDA_Update() 

Dim wshT As Worksheet 
    Dim wbk As Workbook 
    Dim wshS As Worksheet 
    Dim r As Long 
    Dim m As Long 
    Dim cel As Range 
    Application.ScreenUpdating = False 
    Set wshT = ThisWorkbook.Worksheets("Master") 
    On Error Resume Next 

    ' Check whether vda.xlsx is already open 
    Set wbk = Workbooks("vda.xlsx") 
     On Error GoTo 0 
     If wbk Is Nothing Then 
     ' If not, open it 
     Set wbk = Workbooks.Open("C:\Working\vda.xlsx") 
    End If 

    ' Set worksheet on vda.xlsx 
    Set wshS = wbk.Worksheets("pc_list") 
    m = wshT.Cells(wshT.Rows.Count, 1).End(xlUp).Row 

    ' Loop though cells in column J on main.xlsm 
    For r = 1 To m 

     For cCtr = 0 To 2 

     ' Can we find the value in column A of vda.xlsx? 
     Set cel = wshS.Columns(1).Find(What:="EMEA\" + wshT.Cells(r, 10 + cCtr).Value, _ 
     LookAt:=xlWhole, MatchCase:=False) 

     If Not cel Is Nothing Then 

      ' If we find a match, then change cell color 

      If cel.Offset(0, 1).Value = "True" Then 
       wshT.Cells(r, 10 + cCtr).Interior.ColorIndex = 6 
       wshT.Cells(r, 43).Value = "Assigned" 
      ElseIf cel.Offset(0, 1).Value = "False" Then 
       wshT.Cells(r, 10 + cCtr).Interior.ColorIndex = 8 
       wshT.Cells(r, 43).Value = "Unassigned" 
      End If 

      ' If so, enter "Yes" in column M - Comms Sent? 
       ' If wshT.Cells(r, 13).Value = "" Then wshT.Cells(r, 13).Value = "Yes" 
      ' Enter "Yes" in column O - VDA Deployed? 
       If wshT.Cells(r, 15).Value = "" Then wshT.Cells(r, 15).Value = "Yes" 
      ' Enter "5.6.200" in column P - VDA Version 
       If wshT.Cells(r, 16).Value = "" Then wshT.Cells(r, 16).Value = "5.6.200" 
      ' Enter date in column Q - Migration Date 
       ' If wshT.Cells(r, 17).Value = "02/01/2014" Then wshT.Cells(r, 17).Value = "03/03/2014" 

      End If 
     Next 
    Next r 

    Application.ScreenUpdating = True 

End Sub 
+1

'# N/A','# VALUE!','# DIV/0!'와 같이 셀에'wshT.Cells (r, 10 + cCtr) .Value' 오류가 있는지 확인하십시오. on –

+3

** "EMEA \"+ wshT.Cells (r, 10 + cCtr) .Value **를 ** "EMEA \"및 wshT.Cells (r, 10 + cCtr)로 바꾸어보십시오. 텍스트 ** –

답변

1

는 앰퍼샌드 (&)를 사용하는 대신 당신이 합치되는 What:=의 세그먼트 사이에 더하기 (+)의 :

Set cel = wshS.Columns(1).Find(What:="EMEA\" & wshT.Cells(r, 10 + cCtr).Value, _ 
     LookAt:=xlWhole, MatchCase:=False) 

을 하나 개의 셀이있는 경우 값이 검색 숫자 범위 wshT.Cells(r, 10 + cCtr)에 순수한 값으로 입력되면 VBA는 "EMEA \"를 (연결하는 대신) 해당 숫자에 수학적으로 추가하려고 시도합니다. 이 경우 유형 불일치는 텍스트 및 숫자 데이터 유형 중 하나입니다.

관련 문제