每次Excel中的日期更改后,我想添加一个完整的空白行(无公式,最好使用彩色)。
我已经输入了自己的代码,它可以运行,但是在宏运行后出现运行时错误13类型不匹配。
任何帮助将不胜感激
答案 0 :(得分:0)
@WayneP,尝试做这样的事情:
Public Sub InsertBlankRow()
On Error GoTo erro
Dim active_row As Long
Dim last_row As Long
Worksheets("Planilha1").Activate
looping:
last_row = ActiveSheet.Range("A1048576").End(xlUp).Row
For active_row = 3 To last_row
If ActiveSheet.Range("A" & active_row).Value <> ActiveSheet.Range("A" & active_row - 1).Value Then
If ActiveSheet.Range("A" & active_row).Value <> "" And ActiveSheet.Range("A" & active_row + 1).Value <> "" Then
ActiveSheet.Rows(active_row & ":" & active_row).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
active_row = active_row + 1
GoTo looping
ElseIf ActiveSheet.Range("A" & active_row).Value = "" And ActiveSheet.Range("A" & active_row + 1).Value <> "" Then
active_row = active_row + 1
End If
End If
Next active_row
Exit Sub
erro: MsgBox Err.Number & ": " & Err.Description, vbCritical, "Error at InsertBlankRow()"
End Sub