作者:乔山办公网日期:
返回目录:excel表格制作
两个例子,为了说的清楚,分别说明下,copy方法肯定不只这两种,请参考
Sub aaa()
'数组百(arr1)里面 每个值都乘以20.然后再减去100
Dim arr, x
arr = Range("a1:a10")
For x = 1 To UBound(arr)
Dim arr1(1 To 10, 1 To 1)
k = k + 1
arr1(k, 1) = arr(x, 1) * 20 - 100
Next x
Stop
End Sub
Sub afd() '查数组的值大于度4的个数
Dim arr, x, k
arr = Split("1\2\3\4\5", "\")
For x = 1 To UBound(arr)
Cells(x, 2) = arr(x)
Next x
MsgBox Application.CountIf(Range("b:b"), ">4")
End Sub
实现代码如下:
1234567891011121314151617Sub abc() Dim D As Object, i As Integer, index As Integer Set D = CreateObject("scripting.dictionary") With Sheet1 For i = 1 To Range("b65536").End(xlUp).Row D(.Cells(i, 2).Value) = "" Next For i = 1 To Range("a65536").End(xlUp).Row If Not D.Exists(.Cells(i, 1).Value) Then index = index + 1 .Cells(index, 3) = .Cells(i, 1) End If Next End WithEnd Sub
用字百典比较方便,省去重复的循环度过程
如果数据量大,版双层循权环效率是很低的。
你上个图好理解点
每个EXCEL版本的行列是不同的,且是有限制的
列比行少很多
---------------------
第一个问题做了个答案
第二个问题不知道不重复的规则