【问题标题】:look up data left and right (with or without VBA)左右查找数据(使用或不使用 VBA)
【发布时间】:2017-10-16 12:51:29
【问题描述】:

我有一个包含 2 个工作表的 excel 文件。

在名为“数据”的第一个工作表上,我想从名为“列表”的第二个工作表中查找数据。我需要查找的数据来自查找值的左侧和右侧。因此,我想知道您对同时从双方收集数据的最佳公式或代码的建议。

Worksheet 1 name "Data" > Value to look up is in "B7" is "John"

Worksheet 2 name "List" > Matching value to be looked up is in "D7" is "John"
                    > Return a value from "A7" -3 cells to the left
                    > Return a value from "G7" 3 cells to the right

有什么建议吗?

【问题讨论】:

  • 假设“要查找的匹配值在“D7”中”表示匹配值在D列的某处,但是你需要找到哪里,这听起来像MATCHINDEX Excel 函数的工作。
  • 我使用了 MATCH 和 INDEX,它工作得很好。谢谢

标签: excel excel-formula formula lookup vba


【解决方案1】:

不确定你尝试了什么,

但我建议使用 .Find 然后向左和向右偏移。

所以一个例子是:

Msgbox(Worksheets("List").Range("D1:D20").Find(Worksheets("Data").Range("D7").Value).Offset(0,3).Value) Msgbox(Worksheets("List").Range("D1:D20").Find(Worksheets("Data").Range("D7").Value).Offset(0,-3).Value)

另一种选择是使用索引匹配

=Index(List!A:A,Match(Data!B7,List!D:D,0),1) 为它的左边

=Index(List!G:G,Match(Data!B7,List!D:D,0),1) 为它的右边

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-16
    • 1970-01-01
    相关资源
    最近更新 更多