【问题标题】:Many-to-many Files Vlookup or Index-Match basic on specified cell value基于指定单元格值的多对多文件 Vlookup 或索引匹配
【发布时间】:2021-01-01 08:56:02
【问题描述】:

我正在尝试对已关闭的工作簿进行 vlookup;但是,它并不总是相同的工作簿。我希望我可以将文件名引用到特定的单元格值并从那里找到它。这是我的代码。

Sub Vlookup()
Dim FileName As String
Dim Path As String
Dim Formula As String

Path = "C:\Users\Jwbeauch\Desktop\Schools\Chart of Accounts\["
FileName = Range("B1").Value & ".xlsx]COA'!"
Formula = "Vlookup(D3," & Path & FileName & Range("$B$15:$C$1000") & ", 2, 0)"
ActiveCell.Formula = Formula

     
     
End Sub

【问题讨论】:

  • 您遇到了什么问题?当你的代码运行时会发生什么?
  • 嗨蒂姆,我遇到的问题是公式。我收到的错误消息是“运行时错误'13':类型不匹配

标签: excel vba excel-formula vlookup


【解决方案1】:
Sub Vlookup()

Dim FileName As String
Dim Path As String
Dim Formula As String
Dim SheetName As String

Path = "C:\Users\Jwbeauch\Desktop\Schools\Chart of Accounts\"
FileName = "[" & Range("B1").Value & ".xlsx]"
SheetName = "COA" ' Need to enter sheet name you are looking up

Formula = "=VLOOKUP(D3,'" & Path & FileName & SheetName & "'!" & ("$B$15:$C$1000") & ",2,0)"
ActiveCell.Formula = Formula

End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-01
    • 2013-11-01
    • 1970-01-01
    • 2013-05-01
    • 1970-01-01
    • 2013-08-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多