VBA Excel - Insert row below with same format including borders and frames

前端 未结 4 1992
忘了有多久
忘了有多久 2021-02-10 05:53

I want to build a macro that inserts a row below the selected cell with the same format. This is the code I have so far:

Public Sub insertRowBelow()
ActiveCell.         


        
4条回答
  •  故里飘歌
    2021-02-10 06:46

    The easiest option is to make use of the Excel copy/paste.

    Public Sub insertRowBelow()
    ActiveCell.Offset(1).EntireRow.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromRightOrAbove
    ActiveCell.EntireRow.Copy
    ActiveCell.Offset(1).EntireRow.PasteSpecial xlPasteFormats
    Application.CutCopyMode = False
    End Sub
    

提交回复
热议问题