1)在工作表sheet1的A1:F1中输入1~6这6个数字
2)在A3中输入9
3)在工作表界面作如下操作:
标题栏->工具->宏->vixual basic编辑器(单击打开)
在打开的vixual basic编辑器窗口作如下操作:
标题栏->视图->工程资源管理器(单击打开)
双击sheet1(注意你的工作表如果是sheet2,就双击sheet2)
右边出现一大片空白区域
将下述代码复制->粘贴进去
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Integer
[iq1:iv1] = "=rand()"
100:
If Cells(1, 251) > 0.5 Then Cells(2, 1) = "" Else Cells(2, 1) = Cells(1, 1)
If Cells(1, 252) > 0.5 Then Cells(2, 2) = "" Else Cells(2, 2) = Cells(1, 2)
If Cells(1, 253) > 0.5 Then Cells(2, 3) = "" Else Cells(2, 3) = Cells(1, 3)
If Cells(1, 254) > 0.5 Then Cells(2, 4) = "" Else Cells(2, 4) = Cells(1, 4)
If Cells(1, 255) > 0.5 Then Cells(2, 5) = "" Else Cells(2, 5) = Cells(1, 5)
If Cells(1, 256) > 0.5 Then Cells(2, 6) = "" Else Cells(2, 6) = Cells(1, 6)
If [A2] + [b2] + [C2] + [D2] + [E2] + [F2] <> [A3] Then GoTo 100
End Sub
4)任意单击任何单元格,则在第二行中会为你自动显示等于9的和的数字