Excel VBA删除空单元格并向上移动内容
我有这样的数据:
xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx
我想写一个macros从上到下遍历每一列,剪切并粘贴单元格。 这是我的代码与第二列一起工作。
Dim x As Integer, y As Integer x = 1 For y = 1 To 75 If Cells(y, 2).Value <> "" Then Cells(y, 2).Cut Cells(x, 2).Paste x = x + 1 End If Next y
Excel不断告诉我:“对象不支持此属性或方法”在单元格(x,2).Paste上
它根本不运行。 无视75的范围。我只有小数据。
Cells(x, 2).Paste
不是有效的命令。 使用Cells(x, 2).PasteSpecial
尝试使用intellisense来指导你有效的命令。