|
楼主 |
发表于 2019-10-22 08:28
|
显示全部楼层
因为我这两个代码冲突了:不知如何融合
宏1:Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
r = Target.Row: c = Target.Column
s = Sheet2.Cells(r, c)
If s <> Target Then Target.NoteText IIf(s = Target, "", s)
If s <> Target Then Target.Interior.ColorIndex = 36
End Sub
宏2:单元格双击互换值
Dim c As Range, myFlag As Boolean, oldFormat As Long
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim x
'If Target.Count = 1 And Target.Value > "" Then
If myFlag Then
x = c.Value
c.Value = Target.Value
c.Interior.ColorIndex = oldFormat
Target.Value = x
myFlag = False
ActiveWindow.Caption = Left(ActiveWindow.Caption, Len(ActiveWindow.Caption) - 8)
Else
Set c = Target
oldFormat = c.Interior.ColorIndex
c.Interior.ColorIndex = 37
myFlag = True
ActiveWindow.Caption = ActiveWindow.Caption & " 交换开关打开"
'End If
End If
Cancel = True
End Sub
|
|