写了一个简单的代码, 不是很精简, 将就用吧

来源: 2006-10-10 12:36:52 [博客] [旧帖] [给我悄悄话] 本文已被阅读:

我试验过的.




Option Explicit


Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Dim i


If Target.Address = "$A$1" Then
Application.EnableEvents = False
For i = 3 To 200
If Cells(i, 1) = Target.Value Then
Cells(1, 2) = Cells(i, 2)
Application.EnableEvents = True
Exit Sub
End If
Next

For i = 3 To 200
If Cells(i, 3) = Target.Value Then
Cells(1, 2) = Cells(i, 4)
Application.EnableEvents = True
Exit Sub
End If
Next


For i = 3 To 200
If Cells(i, 5) = Target.Value Then
Cells(1, 2) = Cells(i, 6)
Application.EnableEvents = True
Exit Sub
End If
Next

Application.EnableEvents = True
Else
Exit Sub
End If



End Sub