我有一个excel文件,我输入我的统计数据。出于激励目的,当某个单元格达到某个值时,我希望它像成就视频一样播放。就好像我坚持了30天的饮食习惯做得好! 30天的饮食!你现在是饮食学徒! 我真的不知道如何做这个代码。尝试:
Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("dietdays")) Is Nothing Then
Call diet1
End If
End Sub
Sub diet1()
If e2 = 30 Then
Call Shell("e:\1\1.au3")
End If
End Sub
答案 0 :(得分:0)
当你说e2 = 30时,你指的是活动表中的单元格吗?如果是这样,你应该重写你的代码,如下所示:
Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("dietdays")) Is Nothing Then
Call diet1
End If
End Sub
Sub diet1()
Dim Shex As Object:Set Shex = CreateObject("Shell.Application")
'ThisWorkbook.Sheets("Sheet1").Range("E2").value = 30 then
'consider qualifying the Sheet as above instead of using ActiveSheet
If ThisWorkbook.ActiveSheet.Range("E2").Value = 30 Then
FName = "E:\1\1.au3"
Shex.Open (FName)
End If
End Sub