程式如下:
Dim pre As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Application.ScreenUpdating = False
Application.EnableEvents = False
If Application.CutCopyMode = xlCopy Then Me.Paste
On Error Resume Next
If Not pre Is Nothing Then
Cells(Rows.Count, Columns.Count).Copy
pre.PasteSpecial Paste:=xlPasteFormats
End If
Target.Copy
Cells(Rows.Count, Columns.Count).PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False: Target.Select
Target.FormatConditions.Delete
Target.Interior.ColorIndex = 40
Set pre = Target
Application.EnableEvents = True
End Sub
Dim pre As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlManual
If Application.CutCopyMode = xlCopy Then Me.Paste
On Error Resume Next
If Not pre Is Nothing Then
Cells(Rows.Count, Columns.Count).Copy
pre.PasteSpecial Paste:=xlPasteFormats
End If
Target.Copy
Cells(Rows.Count, Columns.Count).PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False: Target.Select
Target.FormatConditions.Delete
Target.Interior.ColorIndex = 40
Set pre = Target
Application.EnableEvents = True
Application.Calculation = xlAutomatic
End Sub
Dim pre As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Application.ScreenUpdating = False
Application.EnableEvents = False
On Error Resume Next
If Application.CutCopyMode = xlCopy Then Me.Paste
Application.Calculation = xlManual
If Not pre Is Nothing Then
Cells(Rows.Count, Columns.Count).Copy
pre.PasteSpecial Paste:=xlPasteFormats
End If
Target.Copy
Cells(Rows.Count, Columns.Count).PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False: Target.Select
Target.FormatConditions.Delete
Target.Interior.ColorIndex = 40
Set pre = Target
Application.EnableEvents = True
Application.Calculation = xlAutomatic
End Sub