如何通过按钮开关excel里的vba,高手请进
一共有5张sheets,sheet1和sheet2有vba代码如下:SubWorksheet_SelectionChange(ByValTargetAsRange)Wit...
一共有5张sheets,sheet1和sheet2有vba代码如下:
Sub Worksheet_SelectionChange(ByVal Target As Range)
With Target
.Parent.Cells.Interior.ColorIndex = xlNone
.EntireRow.Interior.ColorIndex = 15
.EntireColumn.Interior.ColorIndex = 15
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ColorIndex = 48
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub
希望新建一个sheet6,里面放一个按钮控件,点击该按钮就开启sheet1和sheet2里面的代码的功能,再次点击就禁用该代码的功能,请问如何实现? 展开
Sub Worksheet_SelectionChange(ByVal Target As Range)
With Target
.Parent.Cells.Interior.ColorIndex = xlNone
.EntireRow.Interior.ColorIndex = 15
.EntireColumn.Interior.ColorIndex = 15
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ColorIndex = 48
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub
希望新建一个sheet6,里面放一个按钮控件,点击该按钮就开启sheet1和sheet2里面的代码的功能,再次点击就禁用该代码的功能,请问如何实现? 展开
1个回答
2013-09-13
展开全部
可以关闭Excel的事件代码,但不可以单独关闭其中一个或几个工作表的。
按钮代码就一句就可以了:
Application.EnableEvents = Not Application.EnableEvents
按钮代码就一句就可以了:
Application.EnableEvents = Not Application.EnableEvents
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询