-2

我有一个文档,我想在其中创建行之间的换行符以对发票进行分组。

例如,我的文档显示:

H   INV 96579551
N   606R00103216L   2003-
H   INV 96579583
N   606R00103216L   2003-
H   INV 96579584
N   606R00103216L   2003-

但我想创建一个宏,让我的文档看起来像:

H   INV 96579551
N   606R00103216L   2003-

H   INV 96579583
N   606R00103216L   2003-


H   INV 96579584
N   606R00103216L   2003-

谁能给我任何提示?谢谢

4

1 回答 1

0

希望这对你有用(假设你有按排序顺序分组的行)

Sub Test()
    Set selectRows = Cells(3, 1) 'start from 3rd row
    For i = 3 To ActiveSheet.UsedRange.Rows.Count Step 2 'skip 2 rows (H & N group)
        Set selectRows = Union(selectRows, Cells(i, "A")) 'store the ODD cell references - starting from 3rd row
    Next i
    selectRows.EntireRow.Select 'select all the rows stored in the union reference
    Selection.Insert Shift:=xlDown 'simulate Ctrl+ to add a row
    Cells(1, 1).Select 'select the first cell - just to keep it clean :-)
End Sub
于 2013-10-02T11:25:36.697 回答