|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test()
Dim ar, br, cr(), r&, c%, n%, k%
UsedRange.Font.ColorIndex = xlAutomatic
ar = [h5].Resize(5)
br = [n5].Resize(6, 10)
For c = 1 To 10
n = 0
For r = 1 To 5
If br(r, c) = ar(r, 1) Then
n = n + 1
Cells(r + 4, c + 13).Font.Color = vbRed
End If
Next
If n Then
k = k + 1
ReDim Preserve cr(1 To k)
cr(k) = c + 13
End If
Next
''''''''''''''''''''''这是原来的
'For c = 1 To k
' Cells(5, cr(c)).Resize(6).Copy [m18].Offset(0, c)
'Next
''''''''''''''''''''''这是改过的
For c = 1 To k
Cells(5, cr(c)).Resize(6).Copy
With [m18].Offset(0, c)
.PasteSpecial 13 '选择性粘贴 格式
.PasteSpecial -4163 '选择性粘贴 值
End With
Next
[l18].Resize(5) = ar
End Sub |
|