EXCEL VBA重叠错误 [英] EXCEL VBA overlap error

查看:57
本文介绍了EXCEL VBA重叠错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    Range("A1:C7").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Application.CutCopyMode = False
    Selection.EntireRow.Delete 
End Sub

这是已记录的VBA宏的一部分,用于删除空白行,但显示错误运行时错误"1004"-不能在重叠选择上使用该命令" .EntireRow.Delete .

This is part of a recorded VBA macro for deleting blank rows but it's showing an error Run time error "1004" - "cannot use that command on overlapping selection" in the line Selection.EntireRow.Delete.

问题出在哪里?

推荐答案

一个简单的循环示例:

Dim rgCol                 As Range
On Error Resume Next
For Each rgCol In Range("A1:C7").Columns
    rgCol.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Next rgCol

这篇关于EXCEL VBA重叠错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆