|
Public Sub addRow()
Application.DisplayAlerts = False
Dim startRowNo As Integer
Dim startColNo As String
Dim endRowNo As Integer
Dim endColNo As String
Dim changedRowNo As Integer
Dim macroConfigSheet As Worksheet
Set macroConfigSheet = ThisWorkbook.Sheets(2)
startRowNo = macroConfigSheet.Cells(1, 2)
startColNo = macroConfigSheet.Cells(2, 2)
endRowNo = macroConfigSheet.Cells(3, 2)
endColNo = macroConfigSheet.Cells(4, 2)
changedRowNo = macroConfigSheet.Cells(5, 2)
If (endRowNo < startRowNo) Then
MsgBox "Error!"
Exit Sub
Else
'Rows(endRowNo).Copy Rows(endRowNo + 1)
Rows(endRowNo + 1 + changedRowNo).EntireRow.Insert // 这句insert只有第一次插入有用
'Call clearSpecialCell(endRowNo + 1)
'Call clearSpecialCell(changedRowNo + 1)
macroConfigSheet.Cells(3, 2) = endRowNo + 1
macroConfigSheet.Cells(5, 2) = changedRowNo + 1
End If
Application.DisplayAlerts = True
End Sub
Private Sub clearSpecialCell(rowNo As Integer)
On Error GoTo error1
Rows(rowNo).SpecialCells(xlCellTypeConstants).ClearContents
error1:
End Sub
|
|