我运行代码不匹配类型后,我在vba中收到13类错误?可以解决此错误 [英] I am getting type 13 error in vba once i run the code missmatched type?Can please solve this error
问题描述
我运行代码不匹配类型后,我在vba中遇到类型13错误?可以解决此错误
I am getting type 13 error in vba once i run the code missmatched type?Can please solve this error
Sub open_read()
Sub open_read()
Dim i,filenum As Integer
Dim txt As String,x
Var =表格("Sheet3")。范围("A1")                                                        
       
Dim current_path As String
current_path =" xxxxxxxxxxxxxxxxxxxxxxxxx_" &安培; Var& " .txt"
filenum = FreeFile
 打开current_path输入为#filenum
i = 1
直到EOF(1)
行输入#filenum,txt
x =拆分(txt,";")
表格("Sheet1")。范围("A"& i).Resize(,UBound(x)+ 1).Value = x
i = i + 1
循环
关闭filenum
'结束次级
'Sub FilterRangeCriteria()
$
错误GoTo ErrorRoutine
Dim vCrit As Variant < br $>
Dim wsO As Worksheet
Dim wsL As Worksheet
Dim rngCrit As Range
Dim rngOrders As Range
Set wsO = Worksheets(" Sheet1")
Set wsL = Worksheets(" Sheet2")
Set rngOrders = wsO.Range(" $ A $ 1")。CurrentRegion
设置rngCrit = wsL.Range(&"CritList"))
vCrit = rngCrit.Value
$
rngOrders.AutoFilter _
&NBSP;字段:= 1,_
&NBSP; Criteria1:= Application.Transpose(vCrit),_
&NBSP;接线员:= xlFilterValues
&NBSP; Dim LastLine As Long
&NBSP; LastLine = Columns(1).Find(" *",,, xlByColumns,xlPrevious)。$ zh
&NBSP; '复制过滤后的数据。
&NBSP; 范围("A1:N"& LastLine).SpecialCells(xlCellTypeVisible)。复制
&NBSP; '粘贴到Sheet2
&NBSP;表格(2).Range("B1")。PasteSpecial
ErrorRoutine:
&NBSP; MsgBox Err.Description
结束次郎
$
Dim i, filenum As Integer
Dim txt As String, x
Var = Sheets("Sheet3").Range("A1")
Dim current_path As String
current_path = "xxxxxxxxxxxxxxxxxxxxxxxxx_" & Var & ".txt"
filenum = FreeFile
Open current_path For Input As #filenum
i = 1
Do Until EOF(1)
Line Input #filenum, txt
x = Split(txt, ";")
Sheets("Sheet1").Range("A" & i).Resize(, UBound(x) + 1).Value = x
i = i + 1
Loop
Close filenum
'End Sub
'Sub FilterRangeCriteria()
On Error GoTo ErrorRoutine
Dim vCrit As Variant
Dim wsO As Worksheet
Dim wsL As Worksheet
Dim rngCrit As Range
Dim rngOrders As Range
Set wsO = Worksheets("Sheet1")
Set wsL = Worksheets("Sheet2")
Set rngOrders = wsO.Range("$A$1").CurrentRegion
Set rngCrit = wsL.Range("CritList")
vCrit = rngCrit.Value
rngOrders.AutoFilter _
Field:=1, _
Criteria1:=Application.Transpose(vCrit), _
Operator:=xlFilterValues
Dim LastLine As Long
LastLine = Columns(1).Find("*", , , , xlByColumns, xlPrevious).Row
'Copy the filtered data.
Range("A1:N" & LastLine).SpecialCells(xlCellTypeVisible).Copy
'Paste to Sheet2
Sheets(2).Range("B1").PasteSpecial
ErrorRoutine:
MsgBox Err.Description
End Sub
推荐答案
我在vba中收到13类错误一旦我运行代码不匹配类型?可以请解决此错误
I am getting type 13 error in vba once i run the code missmatched type?Can please solve this error
应该在
Visual Basic for Applications (VBA)
当您提出问题时,请务必指出发生错误的代码行,以及每个变量的类型。那行代码。
When you ask your question be sure to indicate the line of code at which the error occurs, and the Type of each variable referred to in that line of code.
这篇关于我运行代码不匹配类型后,我在vba中收到13类错误?可以解决此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!