作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
此致;我有以下代码,我想让它更高效,因为要分析 1,000,000 条记录。非常感谢,为我的英语悲伤道歉。
Sub test()
Sub test()
Dim value1 As Worksheet, value2 As Worksheet
Dim col1 As Long, col2 As Long
Set value1 = Worksheets(2)
Set value2 = Worksheets(2)
For col1 = 2 To value1.Range("A2").End(xlDown).Row
For col2 = 2 To value2.Range("B2").End(xlDown).Row
If value1.Cells(col1, 1).Value = value2.Cells(col2, 2).Value _
And value1.Cells(col1, 1).Value > 0 Then
value1.Cells(col1, 1).Interior.Color = vbYellow
End If
Next
Next
End Sub
最佳答案
我无聊了,为你做了一件事。
Private Sub utqwdelkdfjsvd()
Dim rng As String
Dim i As Long, j As Long
Dim pickup As Variant
pickup = ThisWorkbook.Worksheets("yoursheetname").usedrange
For i = LBound(pickup, 1) To UBound(pickup, 1)
For j = LBound(pickup, 1) To UBound(pickup, 1)
If pickup(i, 1) = pickup(j, 2) And pickup(i, 1) > 0 Then
If i = 1 Then
rng = "a" & i
Else
rng = rng & ", a" & i
End If
End If
Next j
Next i
ThisWorkbook.Worksheets("Sheet1").Range(rng).Interior.ColorIndex = 4
End Sub
关于excel - 如何使这个 VBA 代码 - Excel 更有效率?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56084756/
我是一名优秀的程序员,十分优秀!