您的位置:首页 > 编程语言 > VB

VBA 操作 Excel 数据筛查

2016-09-22 11:06 423 查看
今天要统计程序中用到了哪些表, 统计出来, 发现有很多重复的

就想到用Excel筛一下

Sub cal()
'
' cal 宏
'

Dim num As Integer
Dim dataCol As Integer
Dim maxRow As Integer
Dim resultCol As Integer

num = 1
dataCol = 4
maxRow = 2728
resultCol = 6

For i = 1 To maxRow
For j = i + 1 To maxRow
If Cells(i, dataCol) = Cells(j, dataCol) And Not Cells(j, dataCol).Interior.Color = 65535 Then
Cells(j, dataCol).Interior.Color = 65535
End If
Next
Next

For i = 1 To maxRow
If Not Cells(i, dataCol).Interior.Color = 65535 Then
Cells(num, resultCol) = Cells(i, dataCol)
num = num + 1
End If
Next

End Sub


自定义了一个宏, 处理这个问题
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  excel vba