我的SelectionChange的问题

时间:2012-02-03 20:14:00

标签: excel-2007 vba

我似乎无法让它正常工作

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim LastRow As Long
If Not Intersect(Target, Range("C7,D7,E7,F7,G7,C8,D8,E8,F8,G8,C9,D9,E9,F9,G9,C10,D10,E10,F10,G10,C11,D11,E11,F11,G11")) Is Nothing Then
Application.EnableEvents = False
    With Selection.Borders(xlDiagonalDown)
        .LineStyle = xlContinuous
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
        .Weight = xlThick
        Application.EnableEvents = True
    End With
    With Selection.Borders(xlDiagonalUp)
        .LineStyle = xlContinuous
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
        .Weight = xlThick
   End With
    With Selection.Font
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = -0.249977111117893
    End With
    End If
End Sub

1 个答案:

答案 0 :(得分:2)

您的代码确实有用(或者至少告诉我们什么没有)。

请务必将此代码放在工作表模块中:

  • 选择要应用代码的工作表
  • 右键单击“工作表名称”
  • 点击查看代码...
  • 粘贴您的代码

[编辑]您应该重新激活代码末尾的事件:

Application.EnableEvents = True
相关问题