gpt4 book ai didi

Excel VBA : Cannot use command on overlapping selections

转载 作者:行者123 更新时间:2023-12-04 20:31:04 25 4
gpt4 key购买 nike

我尝试运行以下脚本以删除 Excel 表中的空行。我收到错误:“不能在重叠选择上使用命令”
可能是什么原因?

Dim Rng2 As Range
On Error Resume Next
Set Rng2 = Range("Table2").SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
If Not Rng2 Is Nothing Then
Rng2.Delete Shift:=xlUp
End If

最佳答案

试试下面的。

注意:更改> 0> 1如果需要空格,如果 2 列等

代码:

Option Explicit

Public Sub test()
Dim Rng2 As Range
With ActiveSheet
For Each Rng2 In .Range("Table2").Rows
If Application.WorksheetFunction.CountBlank(Rng2) > 0 Then Rng2.Delete
Next Rng2
End With
End Sub

使用过滤表,您可能需要取消过滤然后删除

关于Excel VBA : Cannot use command on overlapping selections,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50664898/

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