如果值为0,则vlookup将单元格留空

时间:2017-10-02 19:17:28

标签: excel vba excel-vba formula vlookup

到目前为止,我已编写此代码,但是说有应用程序或对象错误..

            '...
            Next k
                unionVariable.Copy               ' all the data added to ShWork
                'Create a temporary sheet (the workbook is being closed without saving
                'so the temporary worksheet will be "lost" after we finish)
                xlWB.Worksheets.Add Before:=xlWB.Worksheets(1)
                'Paste the data into the temporary sheet
                xlWB.Worksheets(1).Range("A1").PasteSpecial xlPasteValues
                'Copy the temporary sheet
                xlWB.Worksheets(1).UsedRange.Copy

tryAgain:

                ActiveWindow.ViewType = ppViewNormal
                '...

到目前为止我已经成功使用了这段代码但是我已经改变了,你现在就不会运行了。

.Formula = "=IF(VLOOKUP(A2&""B2"",MARM!A:G,7,0),"""")=0,"""",VLOOKUP(A2&""B2"",MARM!A:G,7,0),""""))"

编辑后的整个部分,

.Formula = "=IF(IFERROR(I2/VLOOKUP(A2&""B2"",MARM!A:G,7,0),"""")=0,"""",IFERROR(I2/VLOOKUP(A2&""B2"",MARM!A:G,7,0),""""))"

enter image description here

0 个答案:

没有答案