gpt4 book ai didi

excel - 删除空单元格(上移)

转载 作者:行者123 更新时间:2023-12-04 21:37:09 26 4
gpt4 key购买 nike

我下面的代码有什么问题?我想删除空单元格并向上移动其余数据(大约 10 列)

但我收到错误:应用程序定义或对象定义错误。

Sub delete_empty_cells()

Sheets("Incidents_data").Select
Cells.Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Delete Shift:=xlUp
End Sub

最佳答案

将您的单元格删除限制在 Worksheet.UsedRange property .

With Worksheets("Incidents_data")
.UsedRange.Cells.SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp
End With

关于excel - 删除空单元格(上移),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33762396/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com