本文介绍了Excel VBA - 删除空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除我的ERP报价生成的空行。我想通过文档( A1:Z50 )和单元格中没有数据的每一行( A1-B1)。 ..Z1 =空 A5-B5 ... Z5 =空)我想删除它们。



我发现这个,但似乎无法为我配置。

 在错误恢复下一步
Worksheet.Columns(A:A)SpecialCells(xlCellTypeBlanks).EntireRow.Delete
错误GoTo 0


解决方案

如何

  sub foo() 
dim r As Range,As As Long,i As Long
设置r = ActiveSheet.Range(A1:Z50)
rows = r.rows.Count
对于i =行到1步(-1)
如果WorksheetFunction.CountA(r.rows(i))= 0然后r.rows(i)。删除
下一个
End Sub


I would like to delete the empty rows my ERP Quotation generates. I'm trying to go through the document (A1:Z50) and for each row where there is no data in the cells (A1-B1...Z1 = empty, A5-B5...Z5 = empty) I want to delete them.

I found this, but can't seem to configure it for me.

On Error Resume Next
Worksheet.Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0
解决方案

How about

sub foo()
  dim r As Range, rows As Long, i As Long
  Set r = ActiveSheet.Range("A1:Z50")
  rows = r.rows.Count
  For i = rows To 1 Step (-1)
    If WorksheetFunction.CountA(r.rows(i)) = 0 Then r.rows(i).Delete
  Next
End Sub

这篇关于Excel VBA - 删除空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 00:52