WANGL2 发表于 2014-9-21 21:42

a=1: t = time 执行时为何提示“变量未定义”?

Dim t As Date
Dim a
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
x = Target.Row
y = Target.Column
If (3 < x And x < 9) And (y > 7 And y < 13) Then
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 41
    If Target = 1 Then
      a = 1: t = time
    End If
    If Target = 25 And a = 1 Then
      b = time - t
      s = Second(b)
      m = Minute(b)
      MsgBox "用时" & m & "分" & s & "秒", , "时间提示"
      a = 0
    End If
End If
End Sub

这儿有肥猫 发表于 2014-9-21 21:52

加一句,dim t

WANGL2 发表于 2014-9-21 22:00

不报错了,但计时不准。谢谢!

这儿有肥猫 发表于 2014-9-21 22:33

?哪里不准?
页: [1]
查看完整版本: a=1: t = time 执行时为何提示“变量未定义”?