Excel自动合并空白单元格至上一行

使用此代码,可将 Excel 表格中的 空白单元格 自动合并到 上一行

步骤

  1. 打开 Excel 文件。
  2. 选择需要操作的区域。
  3. 运行以下 VBA 代码: vba Sub MergeEmptyCells() Dim cell As Range For Each cell In Selection If IsEmpty(cell) Then If Not IsEmpty(cell.Offset(-1, 0)) Then cell.MergeArea.Select cell.Merge End If End If Next cell End Sub
  4. 确保保存文件,以防数据丢失。

通过这些步骤,您可以轻松实现空白单元格的合并,提升工作效率。

txt 文件大小:287B