我试着去检查,如果单元格区域各有另一范围内检查字符串是在范围内的Excel VBA与筛选命令
这是我当前的代码中定义的值:
Sub CheckInstallationName()
Dim LastRow As Long
With Worksheets(2)
LastRow = .Cells(.Rows.Count, Worksheets(1).Cells(4, 3).Value).End(xlUp).Row
End With
Dim rngA As Range
Set rngA = Range(Worksheets(1).Cells(4, 3).Value & "4:" & Worksheets(1).Cells(4, 3).Value & LastRow)
Dim cellA As Range
Dim InstallationNameRange As Variant
InstallationNameRange = Worksheets(1).Range("B16:B32").Value
For Each cellA In rngA
If UBound(Filter(InstallationNameRange, cellA.Value)) < 0 Then
'Some code
End If
Next cellA
End Sub
在If UBound(filter(InstallationNameRange, cellA.Value)) < 0 Then
我收到错误“运行时错误'13':类型不匹配”,找不到解决方案。可能它是一个非常小的修复。如果没有这个if语句代码工作
做'Debug.Print UBound函数(过滤(InstallationNameRange,cellA.Value))''的前If'。如果它是一个错误,那么这就是你所得到的错误的可能原因。 –
什么是“过滤器”,它在哪里定义? – Vityata
@Vityata过滤器是VBA过滤器中的标准函数(SourceArray,Match,[Include],[Compare])https://msdn.microsoft.com/en-us/library/fat7fw0s(v=vs.90).aspx – SLT