删除选区中的整个空行 [英] Delete whole empty row in a selection

查看:95
本文介绍了删除选区中的整个空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的代码删除选区中的整个空行。当我选择一个单元格时它不起作用........你能纠正我的代码吗?或者告诉我更好的代码吗?

====== ===========================================

Sub DltRwOfBlnkClls()

Dim SelctnRng As Range

Dim i As Long

Dim xRW As Integer

On Error Resume Next

xTitleId ="删除空白单元格行"

Set SelctnRng = Application.InputBox(" Select Range:",xTitleId,SelctnRng.Address,Type:= 8)

如果Err.Number = 424那么

退出Sub

结束如果

错误GoTo 0


xRW = SelctnRng.Find(What:=" *",After:= SelctnRng.Cells(1),Lookat:= xlPart,LookIn:= xlFormulas,SearchOrder:= xlByRows,SearchDirection:= xlPrevious,MatchCase:= False).Row

使用应用

.Calculation = xlCalculationManual

.ScreenUpdating = False

for i = xRW To 1 Step -1

如果WorksheetFunction.CountA(SelctnRng.Rows(i))= 0那么

SelctnRng.Rows(i).EntireRow.Delete < br style ="">
结束如果

下一步


。Calculation = xlCalculationAutomatic

.ScreenUpdating = True

结束

End Sub

解决方案

Hi Mohashin,


感谢您访问我们的论坛。


然后本论坛主要关注一般性问题和反馈Excel客户端。由于您的问题与代码有关,我将把您的主题移到以下专用的Excel MSDN论坛:


https://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev


我们建议适当发布的原因是您将获得最合格的受访者群体,而定期阅读论坛的其他合作伙伴可以分享他们的知识或从您与我们的互动中学习。感谢您的理解。


最好的问候,

Yuki Sun



i use below code to delete whole empty row in a selection. When i select a cell only it is not working........Can u pls correct my code  or advise me better code??
=================================================
Sub DltRwOfBlnkClls()
Dim SelctnRng As Range
Dim i As Long
Dim xRW As Integer
On Error Resume Next
xTitleId = "Delete Rows of Blank Cells"
Set SelctnRng = Application.Selection
Set SelctnRng = Application.InputBox("Select Range:", xTitleId, SelctnRng.Address, Type:=8)
If Err.Number = 424 Then
Exit Sub
End If
On Error GoTo 0

xRW = SelctnRng.Find(What:="*", After:=SelctnRng.Cells(1), Lookat:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
For i = xRW To 1 Step -1
If WorksheetFunction.CountA(SelctnRng.Rows(i)) = 0 Then
SelctnRng.Rows(i).EntireRow.Delete
End If
Next

.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub

解决方案

Hi Mohashin,

Thanks for visiting our forum.

Then this forum mainly focus on general questions and feedback about Excel client. Since your issue is about code, I'll move your thread to the following dedicated MSDN forum for Excel:

https://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

Best regards,
Yuki Sun


这篇关于删除选区中的整个空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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