我想知道如何检查键值是否在数组x()中?但它只是弹出了这张图片。
Public Function Find(ByRef x() As Integer, _
ByVal key As Integer) As Boolean
Dim low1 As Integer
Dim high1 As Integer
Dim i As Integer
'Dim low2 As Integer
'Dim high2 As Integer
low1 = LBound(x)
high1 = UBound(x)
For i = low1 To high1
'For j = low2 To high2
If x(i) = key Then
Find = "Found"
End If
End Function
```
Sub test1()
Dim cell As Range
Dim x() As Integer
Dim a As Integer
Dim i As Integer
Dim j As Variant
Dim temp As Integer
Dim count As Integer
a = Range("A1", [a1].End(xlDown)).count
ReDim x(a) As Integer
For i = 1 To a
x(i) = Range("A" & CStr(i))
Next
count = 1
For Each j In x
Worksheets(1).Cells(count, "B") = Find(j, 18)
count = count + 1
Next
End Sub
希望有人能告诉我该怎么做?
1条答案
按热度按时间czq61nw11#
CDP1802正确地指出,当您显式地声明它必须返回布尔值时,您试图返回字符串类型的变量。
话虽如此,我还是要分享我为这类问题创建的实用程序中的一个函数: