【发布时间】:2021-07-03 04:25:17
【问题描述】:
我正在尝试查看水果列表,并将当前不在数组中的所有水果添加到其中。 (看到 apple 和 orange 不在数组中,因此添加它。然后看到以下苹果在数组中,因此忽略它并继续添加柠檬。)
Public Function IsInArray(stringToBeFound As String, arr As Variant) As Boolean
Dim i
For i = LBound(arr) To UBound(arr)
If arr(i) = stringToBeFound Then
IsInArray = True
Exit Function
End If
Next i
IsInArray = False
End Function
Public Sub Create_INDIVIDUAL_TABLES()
Dim tArray As String
Dim t1 As Integer
Dim t2 As Integer
Dim i As Integer
tArray = Array()
t1 = 3
t2 = 3
i = 0
Do While Cells(t1, "A").Value <> ""
If IsInArray(Cells(t1, "B"), tArray) Then
t1 = t1 + 1
Else
tArray(i) = Cells(t1, "B")
i = i + 1
t1 = t1 + 1
End If
Loop
【问题讨论】: