|
- Public rngadd '设置公共变量储存触发地址
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Target.Count > 1 Or Target.Column > 1 Then Exit Sub
- If Target.Address = rngadd Then Exit Sub Else rngadd = Target.Address '防止重复触发
- If Len(Target) > 2 Then
- a = Left(Target, 1) & "-" & Mid(Target, 2, 1) & "-" & Mid(Target, 3)
- b = Left(Target, 1) & "-" & Mid(Target, 2, 2)
- If Len(Target) > 3 Then b = b & "-" & Mid(Target, 4)
- x = Application.InputBox("1) " & a & Chr(10) & "2) " & b, "请选择输入结果", "请输入1或2确定类型", , , , , 1)
- If x = 1 Then Target = a
- If x = 2 Then Target = b
- End If
- End Sub
复制代码 |
|