VBA VLookUp无法正常工作 [英] VBA VLookUp not working

查看:76
本文介绍了VBA VLookUp无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在VBA中使用VLookUp函数.它带有错误无法获取worksheetFunction类的VLookUp属性"它正在尝试从名为13.09.2017的工作表中获取数据

Hi I am trying to use the VLookUp function in VBA. It comes with the error, " Unable to get the VLookUp property of the worksheetFunction class" It is trying to take data from a sheet called 13.09.2017

Sub VLookUp()

Dim i As Integer

Dim k As Integer

For i = 1 To 10

 ThisWorksheet.Cells(1 + i, 11) = WorksheetFunction.VLookUp(Cells(1 + i, 2), Worksheets("13.09.2017").Range("B2:K11"), 10, False)

Next

End Sub 

在此处输入图片描述希望您能帮助我

推荐答案

ThisWorksheet 问题旁边,您的代码将在vlookup在范围内找不到值的第一个实例上中断.如果这是您将要运行的唯一代码,则添加 On Error Resume Next 语句以避免错误.

Beside ThisWorksheet issue, your code will break on first instance where vlookup doesn't find value in range. If this is the only code you will be running, then add On Error Resume Next statement to avoid error.

Sub VLookUp()

    Dim i As Integer
    Dim k As Integer
    On Error Resume Next
    With ActiveSheet
    For i = 1 To 10
        .Cells(1 + i, 11) = WorksheetFunction.VLookUp(.Cells(1 + i, 2), _
            Worksheets("13.09.2017").Range("B2:K11"), 10, False)
    Next
    End With
End Sub

这篇关于VBA VLookUp无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆