1、首先打开Microsoft Office Excel 2007,文件保存为《Excel数据怎样快速向下填满空格》,如下图。
2、然后按下快捷键ALT+F11打开VBA(宏)编辑界面,然后点菜单栏【插入】下拉中列表中点【模块(M)】如图。
3、然后插入了一个模块1,在代码框中复制如下代码:Sub 数据向下空格填充() '2020-5-14 22:26:27 Dim myrange As Range, i As Long, mb As Range, j As Long, c As Long, r As Long On Error Resume Next Set myrange = Selection c = myrange.Columns.Count r = myrange.Rows.Count For i = 1 To c For j = 1 To r If myrange.Cells(j, i).Value <> "" Then Set mb = myrange.Cells(j, i) If myrange.Cells(j, i).Value = "" And mb.Value <> "" Then mb.Copy myrange.Cells(j, i) End If Next j Set mb = Nothing Next iEnd Sub
4、以上操作动态过程如下:
5、回到工作表窗口,首先选原数据表,然后运行【数据向下空格填充】宏(菜单栏中点【视图】中下列表中【宏】列表【查看宏(V)】打开宏对方框,选该宏名),输出结果,运行过程如下图。