我有以下问题;
对于筛选的数据,我希望应用规则A2=B2、A4=B4等
我尝试了下面的代码,但它不起作用,它只接受B2的第一个值
Sub SpecialLoop()
Dim cl As Range, rng As Range
x = 1
Set rng = Range("A2", Range("A2").End(xlDown)).Cells.SpecialCells(xlCellTypeVisible)
For Each cl In rng.SpecialCells(xlCellTypeVisible)
cl = Range("B2", Range("B2").End(xlDown)).Cells.SpecialCells(xlCellTypeVisible)
Next cl
End Sub
2条答案
按热度按时间bvuwiixz1#
代替
cl = Range("B2", Range("B2").End(xlDown)).Cells.SpecialCells(xlCellTypeVisible)
试试这个:
cl.Value = cl.Offset(0, 1).Value
yiytaume2#
如果只是将B列复制到A列,则根本不需要循环: