我需要一个脚本(Excel VBA),它会删除电子表格中空白行 <星期一&#39;出现 - 有人可以帮忙吗?
在下面的示例中,我需要星期一在一起(没有空行)
name Monday 02 05 16
name Monday 02 05 16
name Monday 02 05 16
name Monday 02 05 16
name Tuesday 03 05 16
name Tuesday 03 05 16
答案 0 :(得分:1)
试试这个
Option Explicit
Sub MAIN()
Dim cell As Range
Dim mondaysAddress As String
With Worksheets("MyWS") '<~~ replace "MyWS" with you actual worksheet name
For Each cell In .Columns("A").SpecialCells(xlCellTypeConstants, xlTextValues)'<~~ replace "A" with whatever column cells you must search the word "Monday" in
If InStr(UCase(cell.Value), "MONDAY") Then
If IsEmpty(cell.Offset(1)) Then mondaysAddress = mondaysAddress & cell.Offset(1).Address & ","
End If
Next cell
mondaysAddress = Left(mondaysAddress, Len(mondaysAddress) - 1)
Range(mondaysAddress).EntireRow.Delete
End With
End Sub