我有一张电子表格,在N1栏中:N7,N8:N1,N17:N24,N26:N33,N28:N35和N36:43有vlookup公式,它带来了来自sheet1的结果,如果错误,这可能是弹出(Vlookup找不到结果)消息框,“请在产品表1中添加新产品和规格”。
由于
答案 0 :(得分:1)
您可以在没有VBA处理VLOOKUP的情况下执行此操作(不明白为什么不这样做)
在ThisWorkbook模块中尝试这样的事情。
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
dim rng as Range
application.ScreenUpdating = False
set ws = ActiveSheet
with ws
NoRow = .Cells(.Rows.Count, "N").end(xlUp).Row
set rng = Range(.Cells(1, "N"), .Cells(NoRow, "N"))
end with
If Not Intersect(rng, Range(Target.Address)) Is Nothing Then
for each cell in rng.cells
if cell.value = "#N/A" Then
cell.select
Msgbox "Please add new product and specification in Product Sheet1 for selected cell"
end if
next cell
end if
application.screenupdating = True
end Sub
如果您无法在VBA中处理VLOOKUP功能,那么可以获得更好的结果
重申 - 完全在VBA中执行此操作