Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Application.CutCopyMode = xlCopy Then Me.Paste
On Error Resume Next
[colorCell].FormatConditions.Delete
Target.Name = "colorCell"
With [colorCell].FormatConditions ' 設定格式化條件
.Delete
.Add xlExpression, , "TRUE" ' 條件(一)內公式為
.Item(1).Interior.ColorIndex = 40 ' .Item(1)等於FormatConditions(1)
.Item(1).Font.Bold = True
End With
End Sub
上述程式是網路上所寫的程式
程式如下:
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作者: Hyuan 時間: 2018-12-5 06:26
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作者: n7822123 時間: 2018-12-5 13:01
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作者: Hyuan 時間: 2018-12-5 20:06