我想在一个简单的VBA函数使用VLOOKUP,但它不断地返回#VALUE!
下面是代码:
Public Function getAreaName(UBR As Integer) As String
Dim result As String
Dim sheet As Worksheet
Set sheet = ActiveWorkbook.Sheets("UBR Report")
' check level 3 then 2 then 4 then 5
result = Application.WorksheetFunction.VLookup(UBR, sheet.Range("UBRLookup"), Application.WorksheetFunction.Column(sheet.Range("UBRLookup[Level 3]")), False)
getAreaName = result
End Function
有什么想法?
我使用excel 2007 tablename [column]语法和column()函数来自动确定偏移量。不过,我会尝试使用手动设置。 – jwoolard 2009-08-21 15:13:22
更新了上述内容。 Debug.Print注释是否在您的Excel 2007版本上运行? – Andy 2009-08-25 08:51:55