代码插入一行不能复制上一行数据及格式,麻烦老师修改一下。谢谢
代码
Private Sub CommandButton1_Click()
Sheets("期数表").Activate
Dim Rng As Range
For Each Rng In ActiveSheet.Range("A:A")
If Rng = "胆码" Then
Sheets("期数表").Rows(Rng.Row).Insert
Exit For
End If
Next
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i&
Sheets("期数表").Activate
Dim Rng As Range
For Each Rng In ActiveSheet.Range("A:A")
If Rng = "胆码" Then
i = Rng.Row
Exit For
End If
Next
Set Rng = Application.Intersect(Target, Range(Cells(i, "c"), Cells(i + 5, "cd")))
If Not Rng Is Nothing Then
If Rng.Interior.Color = vbRed Then
Rng.Interior.ColorIndex = xlNone
Else
Rng.Interior.Color = vbRed
End If
End If
[A1].Select
End Sub