批量插入空白行的方式不唯一,可以通過排序的方式,定位法插入,也可以通過函數的方式,還能通過VBA自動化實現,本例先主要講述VBA自動化實現。
首先第一個使用VBA的話,需要注意:
第一個把xlsx格式另存為xlsm格式(文件--另存為--(選中保存位置)--保存類型(Excel啟動宏的工作簿))
![]()
第二個:調出開發工具
文件--更多-選項--自定義功能區--開發工具
![]()
![]()
第三個:開發工具--Visual Basic
彈出功能框
![]()
插入--模塊
![]()
將下列代碼復制到窗口中
Sub insertBlank()
Dim n As Integer
n = Range("a1", Cells(Rows.Count, 1).End(xlUp)).Rows.Count
For i = 2 To 2 * n Step 2
Rows(i).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Next
End Sub
![]()
點擊保存,關閉窗口
開發工具--宏
![]()
選擇執行
![]()
結果
![]()
特別聲明:以上內容(如有圖片或視頻亦包括在內)為自媒體平臺“網易號”用戶上傳并發布,本平臺僅提供信息存儲服務。
Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.