第一行保持事件的完整參數
Private Sub WORKSHEET_CHANGE(ByVal Target As Range)
就可以執行了作者: e19821223 時間: 2013-9-17 16:14
感謝O大的回覆 我依照O大所打的 改成
Private Sub WORKSHEET_CHANGE(ByVal Target As Range)
Dim data As Range
Set data = ['sheet2'!$A$1B$10]
[b1] = Application.WorksheetFunction.VLookup([a1], data, 2, 0)
End Sub
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim data As Range, Y As Variant
Application.EnableEvents = False
If Not Intersect(Target, [A1:A10]) Is Nothing Then
' Set data = ['sheet2'!$A$1:B$25]
'Y = Application.VLookup(Target, data, 2, 0)
Y = Application.VLookup(Target, ['sheet2'!$A$1:B$25], 2, 0)
Target.Offset(, 1) = IIf(IsError(Y), "", Y)
End If
Application.EnableEvents = True
End Sub