gpt4 book ai didi

vba - 将 Iferror 函数添加到 VBA

转载 作者:行者123 更新时间:2023-12-04 22:32:53 26 4
gpt4 key购买 nike

你如何在这段代码中注入(inject) iferror 函数?

For d = 2 To lastrowx2

Worksheets("Educational Service Report").Cells(d, 16).Value = Application.WorksheetFunction.VLookup( _
Worksheets("Educational Service Report").Cells(d, 15).Value, _
Worksheets("Educational Service Report").Range("X:Y"), 2, 0)

Next

如果它是一个错误,我只想要一个空值单元格(d,16)。

最佳答案

像下面这样的东西会为你做这件事,一个嵌套的应用程序函数:

For d = 2 To lastrowx2

Worksheets("Educational Service Report").Cells(d, 16).Value = Application.IfError( _
Application.VLookup(Worksheets("Educational Service Report").Cells(d, 15).Value, _
Worksheets("Educational Service Report").Range("X:Y"), 2, 0), "")

Next d

关于vba - 将 Iferror 函数添加到 VBA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51397973/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com