我已經啓動了一個Excel宏,在選擇後插入一個空行,但我想要空白rowheight = 6
。我是VBA新手,但很想學習。如何插入特定高度的空行進行選擇?
這是針對正在工作的項目。
Dim Rng As Range
Dim WorkRng As Range
Dim FirstRow As Integer, xRows As Integer, xCols As Integer
On Error Resume Next
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", WorkRng.Address, Type:=8)
FirstRow = WorkRng.Row
xRows = WorkRng.Rows.count
xCols = WorkRng.Columns.count
Application.ScreenUpdating = False
WorkRng.Cells(xRows, 1).Resize(1, xCols).Select
Do Until Selection.Row = FirstRow
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Offset(-1, 0).Select
Loop
Application.ScreenUpdating = True
End Sub
從右腳開始。停止使用錯誤恢復下一步,直到你知道如何。 http://www.cpearson.com/Excel/ErrorHandling.htm – niton