Excel VBA运行时错误'13'传递长字符串值时类型不匹配

时间:2019-12-21 07:28:12

标签: excel vba type-conversion

运行以下代码时出现错误

    Public Sub TC_Capture()
    Dim fso As Object, Fileout As Object, Sql As Object, objNet As Object, FS As Object, CommandTimeout As Integer
    Set cn = New ADODB.Connection
    Set cm = New ADODB.Command

    Set Rec_set = New ADODB.Recordset
    Set fso = CreateObject("Scripting.FileSystemObject")


    Dim ip As String, db As String, Row As Integer, SharepointAddress As String, LocalAddress As String, UserID As String, PASS As String, ws As Worksheet, ws1 As Worksheet, ws2 As Worksheet, ws3 As Worksheet, Status As String, Status1 As String, Status2 As String, Status3 As String, Status4 As String
    Row = 1
    Dim fndList As Variant                                                              ' find list
    Dim rplcList As Variant                                                             ' replace list
    Dim x As Long

    fndList = Array(Sheets("INDEX").Range("E66").Value, Sheets("INDEX").Range("E67").Value, Sheets("INDEX").Range("E68").Value, Sheets("INDEX").Range("E69").Value, Sheets("INDEX").Range("E70").Value, Sheets("INDEX").Range("E71").Value)                        

    rplcList = Array(Sheets("INDEX").Range("E17").Value, Sheets("INDEX").Range("E18").Value, Sheets("INDEX").Range("E19").Value, Sheets("INDEX").Range("E20").Value, Sheets("INDEX").Range("E21").Value, Sheets("INDEX").Range("E22").Value)                           


    For x = LBound(fndList) To UBound(fndList)                                        replace text
        Sheets("Test Case1").Cells.Replace What:=fndList(x), Replacement:=rplcList(x), _
        LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
        SearchFormat:=False, ReplaceFormat:=False 
    Next i

在查找列表中传递以下值: LANG_CD,CO_BUS_CD,DATA_SRC_CD,DATA_SUB_SRC_CD,CO_BUS_NM,CO_BUS_ABBR_NM,COPRVDINSWRTY_CD,CO_BUS_TYPE_CD,ADDR_LINE1_TX,ADDR_LINE2_TX,CITY_NM,ST_ABBR_CD,ZIP_CD,CNTRY_CD,PHN_CITY_AREA_CD,PHN_NB,PHN_CNTRY_CD,TEST_CO_BUS_CD,GTD_MAX_DAY_NB,INBNKRELATCOBUS_CD,BUSPRTFLOTAGTYP_CD,TEST_OFFST_NB,TEST_FCDLRPREFX_CD,TEST_OFFST_DEC_NB

当我传递最小值(上述值的一半)时,类型不匹配就没有问题。当我传递以上完整值时,我得到了错误类型不匹配。

我曾尝试在 Dim fndList As Variant'查找列表 Dim rplcList As Variant'替换列表 昏暗x长久

但是它们都不起作用。

请建议我解决此问题。

0 个答案:

没有答案