|
楼主 |
发表于 2013-10-11 09:18
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
zhaogang1960 发表于 2013-1-29 12:52
请参考:
Sub 字典法()
Dim d(1 To 3) As Object, t, arr(1 To 2), brr(), i&, j&, m&, sh As Worksheet
For i = 1 To 3
Set d(i) = CreateObject("scripting.dictionary")
Next
For l = 1 To 2
arr(l) = Sheets("Sheet" & l).[a1].CurrentRegion
For i = 1 To UBound(arr(l))
d(l)(arr(l)(i, 1)) = i
Next
Next
ReDim brr(0 To UBound(arr(1)), 1 To 4)
For i = 1 To UBound(arr(1))
If d(1).Exists(arr(1)(i, 1)) And d(2).Exists(arr(1)(i, 1)) Then
For j = 1 To 4
brr(m, j) = arr(1)(i, j) '相同记录
Next
d(1).Remove (arr(1)(i, 1)) 'Sheet1独有
m = m + 1
End If
Next
On Error Resume Next
Set sh = Sheets("相同记录")
If Not sh Is Nothing Then sh.Cells.Clear Else Sheets.Add.Name = "相同记录"
Sheets("相同记录").[a1].Resize(m, 4) = brr
t = d(1).items
For i = 0 To d(1).Count - 1
For j = 1 To 4
brr(i, j) = arr(1)(t(i), j)
Next
Next
Set sh = Sheets("Sheet1独有")
If Not sh Is Nothing Then sh.Cells.Clear Else Sheets.Add.Name = "Sheet1独有"
Sheets("Sheet1独有").[a1].Resize(i, 4) = brr
End Sub
赵大师:这个程序用起来,Sheet1独有表中各个列总的数字都变成科学计数法了,怎么才能把各个列都变成文本格式来显示数字呢? |
|