vba:union方法 并集
Posted pgymeitianjinbu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vba:union方法 并集相关的知识,希望对你有一定的参考价值。
'Application.Union 方法
'返回两个或多个区域的合并区域
'
Sub test()
Range("a1:b3,c5:d8").Select '文本地址引用方式
Union([a1:b3], [c5:d8]).Select '单元格区域引用方式
End Sub
'小结:虽然range也可以完成多区域的引用
'但文本地址的引用方式最多不能超过256个字符
'而union却没有这个限制
'我们经常利用变量与union进行单元格的连接
Sub 连接符单元格连接()
Dim rng As Range
For Each rngs In [b2:b10]
adss = rngs.Address
ads = ads & rngs.Address & ","
Next
ad = Left(ads, Len(ads) - 1)
End Sub
Sub union单元格连接()
Dim rng As Range, rngs As Range
Set rng = [b2]
For Each rngs In [b2:b10]
adss = rngs.Address
Set rng = Union(rng, rngs)
ads = rng.Address
Next
End Sub
案例
Sub 条件筛选()
For Each rng In Range([b2], Cells(Application.CountA([a:a]), 2))
If rng > 90 Then
k = k + 1
If k = 1 Then
Set rn = rng
Else
Set rn = Union(rn, rng)
aa = rn.Address
End If
End If
Next
For Each rngs In rn
n = n + 1
Cells(n + 1, "d") = Cells(rngs.Row, "a")
Cells(n + 1, "e") = rngs
Next
End Sub
[转载]c# Intersect 交集,Except 差集,Union 并集
Intersect 交集,Except 差集,Union 并集
int[] oldArray = { 1, 2, 3, 4, 5 };
int[] newArray = { 2, 4, 5, 7, 8, 9 };
var jiaoJi = oldArray.Intersect(newArray).ToList();//2,4,5
var oldChaJi = oldArray.Except(newArray).ToList();//1,3
var newChaJi = newArray.Except(oldArray).ToList();//7,8,9
var bingJi = oldArray.Union(newArray).ToList();//1,2,3,4,5,7,8,9
以上是关于vba:union方法 并集的主要内容,如果未能解决你的问题,请参考以下文章
R语言union函数计算数据对象(vectorlistdataframe)的并集:union函数计算两个vector向量dataframe列表list的并集
GlobalMapper精品教程046:空间操作——并集(Union)
sql union(并集)EXCEPT(差集)intersect(交集)