wps宏运行时错误13类型不匹配
Sub AAA() Dim dic As New Dictionary Dim dicT As New Dictionary With Sheet1 ER1 = .Range("A" & .Rows.Count).End(3).Row If ER1 <= 1 Then MsgBox "没有关键词!" Exit Sub End If arr = .Range("A1").Resize(ER1).Value For i = 2 To UBound(arr) temp = Trim(LCase(arr(i, 1))) If InStr(temp, " ") <= 0 Then dic(temp) = 1 Else dicT(" " & temp & " ") = 1 End If Next arrKS = dicT.Keys dicT.RemoveAll er2 = .Range("B" & .Rows.Count).End(3).Row For i = 2 To er2 temp = .Range("B" & i).Value If temp <> "" Then dicT(temp) = 1 End If Next If dicT.Count > 0 Then arrWS = dicT.Keys Else MsgBox "请填入替换内容所在表名!" Exit Sub End If dicT.RemoveAll er3 = .Range("C" & .Rows.Count).End(3).Row For i = 2 To er3 temp = .Range("C" & i).Value If temp <> "" Then dicT(temp) = 1 End If Next If dicT.Count > 0 Then arrCol = dicT.Keys Else MsgBox "请填入替换内容所在列名!" Exit Sub End If End With With Application.FileDialog(msoFileDialogOpen) .InitialFileName = ThisWorkbook.Path .AllowMultiSelect = False .Title = "选择处理文件" .Filters.Clear .Filters.Add "xlsx文件", "*.xlsx" .Filters.Add "所有文件", "*.*" If .Show = -1 Then strFName = .SelectedItems.Item(1) PFile strFName, dic, arrKS, arrWS, arrCol End If End With End Sub Sub PFile(strFName, dic As Dictionary, arrKS, arrWS, arrCol) Application.ScreenUpdating = False Dim wb As Workbook Dim ws As Worksheet' Set wb = Workbooks.Open(strFName) Set wb = FindWorkbook(strFName) If wb Is Nothing Then MsgBox FNameTemp & "_文件打开失败!" Exit Sub End If For i = 0 To 0 'UBound(arrWS) Set ws = FindWS(wb, arrWS(i)) If ws Is Nothing Then strMsg = wb.Name & " _ " & "未找到[" & arrWS(i) & "]表" MsgBox strMsg GoTo line1 End If Dim strWSName As String strWSName = ws.Name CN = UBound(arrCol) Dim arrCI() ReDim arrCI(0 To CN) For ii = 0 To CN strColName = arrCol(ii) colN = FindCol(ws, strColName) If colN = 0 Then strMsg = ws.Parent.Name & " _ " & "未找到[" & strColName & "]列" MsgBox strMsg GoTo line1 End If arrCI(ii) = colN Next For ii = 0 To CN PX1 ws, arrCI(ii), dic, arrKS Next Next
Dim dic As New Dictionary
这个自定义类型你没有定义,程序无法运行。所以,你上传的代码不全。
仅仅这一句来说,
temp = Trim(LCase(arr(i, 1)))
没有问题。