vba交集代码怎么在EXCEL中运用vba交集代码怎么在表格EXECL中运用?下面这个是VBA交集代码不知道是否正确,Functionf(x,y)DimdicAsObjectSetdic=CreateObject("Scripting.Dictionary")x=Replace(x,"£¬",",")y=
vba交集代码怎么在表格EXECL中运用?下面这个是VBA交集代码不知道是否正确,
Function f(x,y)
Dim dic As Object
Set dic = CreateObject("Scripting.Dictionary")
x = Replace(x,"£¬",",")
y = Replace(y,"£¬",",")
a = Split(x,",")
b = Split(y,",")
For i = 0 To UBound(a) - 1
dic(a(i)) = ""
Next i
For i = 0 To UBound(b) - 1
If dic.exists(b(i)) Then f = f & b(i) & ","
Next i
Set dic = Nothing
End Function
A1=01,02,05,07,09
A2=02,05,08,13
A3=04,05,12,16,19
A4=03,05,18,19
A5=01,05,11,17,20
A6=1.2.5.6.9.10.22
A7=5.13.16.19.26.24
A8=3.5.10.11.15.17
求这8组数据的交集,
Public Function getJiaoJi(rng As Range) As String
On Error GoTo L_end
Dim d1 As Dictionary, d2 As Dictionary
Set d1 = New Dictionary: Set d2 = New Dictionary
Dim cel As Range
Dim tempstr() As String,temp as string
Dim star As Boolean
Dim i As Integer
Dim ky As Variant
For Each cel In rng
temp = cel.value
if instr(1,temp ,".")>0 then temp = temp.replace(temp ,".",",")
tempstr = Split(temp , ",")
For i = 0 To UBound(tempstr)
If star Then
If d2.Exists(tempstr(i)) Then
If Not d1.Exists(tempstr(i)) Then Call d1.Add(tempstr(i), tempstr(i))
Else
End If
Else
If Not d1.Exists(tempstr(i)) Then Call d1.Add(tempstr(i), tempstr(i))
If Not d2.Exists(tempstr(i)) Then Call d2.Add(tempstr(i), tempstr(i))
End If
Next
star = True
d2.RemoveAll
For Each ky In d1.Keys
Call d2.Add(ky, ky)
Next
d1.RemoveAll
Next
Dim str1 As String
For Each ky In d2.Keys
If str1 = "" Then
str1 = ky
Else
str1 = str1 & "," & ky
End If
Next
getJiaoJi = str1
Exit Function
L_end:
getJiaoJi = "err:" & Err.Description
End Function
甲乙两艘船同时从A码头击发,运送货物到B码头.甲轮船平均每小航行40...甲乙两艘船同时从A码头击 2020-05-22 …
一艘货轮和一艘巡逻舰一起从A码头到B码头,货轮速度每小时20公里,巡逻舰速度每小时100公里,A码 2020-06-18 …
一艘货轮和一艘巡逻艇一起从A码头到B码头,货轮速度每小时20公里,巡逻艇速度每小时100公里,A码 2020-06-18 …
A、B两个码头间的水路为90千米,其中A码头在上游,B码头在下游,第一天,水速为每小时3千米,甲、 2020-07-03 …
A码头在B码头的上游,“2010”号遥控航模从A码头出发,在两个码头之间往返航行,已知舰模在静水中 2020-07-04 …
快艇从A码头出发,沿河顺流而下,途经B码头后继续顺流驶向C码头,到达C码头后立即反向驶回B码头,共 2020-07-11 …
使用X86汇编语言或C语言,要求不使用乘除运算,实现a*b运算(a和b均为8位定点整数补码机器数) 2020-11-20 …
如图①,在第一个天平上,砝码A的质量等于砝码B加上砝码C的质量;如图②,在第二个天平上,砝码A加上砝 2020-11-25 …
用方程解答并用等量关系式甲乙两艘轮船同时从A码头出发,运送货物到B码头.甲轮船平均每小时航行40千米 2020-11-28 …
A、B两码头相距120千米,水速为2千米/小时,从A码头到B码头为顺水航行.当甲、乙两船同时从A、B 2020-12-09 …