如何删除Excel单元格内的空行?

Lou*_*ain 5 excel excel-formula

我在一个 Excel 单元格中有多行文本。我想删除该文本中的所有空白行。我必须明确我不想删除所有换行符。

示例A:

There is a place where the sidewalk ends
And before the street begins,
And there the grass grows soft and white,

And there the sun burns crimson bright,
And there the moon-bird rests from his flight

To cool in the peppermint wind.
Run Code Online (Sandbox Code Playgroud)

...应该翻译成:

There is a place where the sidewalk ends
And before the street begins,
And there the grass grows soft and white,
And there the sun burns crimson bright,
And there the moon-bird rests from his flight
To cool in the peppermint wind.
Run Code Online (Sandbox Code Playgroud)

示例B:






There is a place where the sidewalk ends
And before the street begins,
And there the grass grows soft and white,
And there the sun burns crimson bright,
And there the moon-bird rests from his flight

To cool in the peppermint wind.



Run Code Online (Sandbox Code Playgroud)

...应该翻译成:

There is a place where the sidewalk ends
And before the street begins,
And there the grass grows soft and white,
And there the sun burns crimson bright,
And there the moon-bird rests from his flight
To cool in the peppermint wind.
Run Code Online (Sandbox Code Playgroud)

我想删除空行,因为:

  • 查看电子表格,某些单元格可能看起来是空的,但实际上它们在几行空行后面确实有文本

  • 我需要清理数据以导入到另一个存储解决方案中

Microsoft 有一些有关如何删除 Excel 中的空格的文档。

但它并没有具体描述删除空行的解决方案:

Por*_*ner 3

VBA解决方案:

Sub DoubleReturn()
    Range("A1").Select
    Selection.Replace What:="" & Chr(10) & "" & Chr(10) & "", Replacement:="" & Chr(10) & ""
End Sub
Run Code Online (Sandbox Code Playgroud)

非VBA解决方案:

在查找框中:ALT+0010(两次)表示两次回车。

在替换框中:ALT+0010(一次)