联接2个表(无超级查询-Macbook,索引/匹配太慢)-潜在的VBA选项?

时间:2019-05-16 20:27:40

标签: excel vba

我想加入2张桌子。我知道我可以通过电源查询来做到这一点,但是不幸的是,就像在Macbook上一样,我做不到。有没有人有什么建议? (我想在VBA中尝试这样做吗?)我在使用VBA之前创建了数据透视表,但从未加入2个表。我的目标是从结果表创建数据透视表(将表1和表2合并后得到结果表)。

表1

外键:分区和位置

Division | Year | Week | Location | SchedDept | PlanNetSales | ActNetSales | AreaCategory 
 ----------|------|------|----------|-----------|--------------|-------------|-------------- 
         5 | 2018 |   10 |      520 |       541 |       1943.2 |    2271.115 | Non-Comm     
         5 | 2018 |   10 |      520 |       608 |       4378.4 |    5117.255 | Non-Comm     
         5 | 2018 |   10 |      520 |      1059 |       1044.8 |     1221.11 | Comm         
         5 | 2018 |   10 |      520 |      1126 |         6308 |    7372.475 | Non-Comm     
         5 | 2018 |   10 |      520 |      1605 |       1119.2 |    1308.065 | Non-Comm     
         5 | 2018 |   10 |      520 |       151 |       2995.2 |     3500.64 | Non-Comm     
         5 | 2018 |   10 |      520 |      1637 |       6371.2 |     7446.34 | Non-Comm     
         5 | 2018 |   10 |      520 |      3081 |       1203.2 |     1406.24 | Non-Comm     
         5 | 2018 |   10 |      520 |      6645 |       7350.4 |     8590.78 | Vendor Paid  
         5 | 2018 |   10 |      520 |       452 |       1676.8 |     1959.76 | Non-Comm     
         5 | 2018 |   10 |      520 |       527 |         7392 |      8639.4 | Non-Comm     
         5 | 2018 |   10 |      520 |       542 |       6824.8 |    7976.485 | Non-Comm     
         5 | 2018 |   10 |      520 |       824 |       1872.8 |    2188.835 | Non-Comm     
         5 | 2018 |   10 |      520 |      1201 |       6397.6 |    7477.195 | Non-Comm     
         5 | 2018 |   10 |      520 |      1277 |       2517.6 |    2942.445 | Non-Comm     
         5 | 2018 |   10 |      520 |      1607 |       2196.8 |     2567.51 | Vendor Paid  
         5 | 2018 |   10 |      520 |       104 |       3276.8 |     3829.76 | Non-Comm     

表2

外键:分区和位置

  Division | Location | LocationName | Region | RegionName | District | DistrictName 
 ----------|----------|--------------|--------|------------|----------|-------------- 
         5 |      520 | Location 520 |      1 | Region 1   |        1 | District 1   
         5 |      584 | Location 584 |      1 | Region 1   |        1 | District 1   
         5 |      492 | Location 492 |      1 | Region 1   |        2 | District 2   
         5 |      215 | Location 215 |      1 | Region 1   |        3 | District 3   
         5 |      649 | Location 649 |      1 | Region 1   |        4 | District 4   
         5 |      674 | Location 674 |      1 | Region 1   |        1 | District 1   
         5 |      139 | Location 139 |      1 | Region 1   |        1 | District 1   
         5 |      539 | Location 539 |      1 | Region 1   |        5 | District 5   
         5 |      489 | Location 489 |      1 | Region 1   |        5 | District 5   
         5 |      139 | Location 139 |      1 | Region 1   |        1 | District 1   
         5 |      161 | Location 161 |      1 | Region 1   |        6 | District 6   
         5 |      543 | Location 543 |      1 | Region 1   |        4 | District 4   
         5 |      166 | Location 166 |      1 | Region 1   |        6 | District 6   
         5 |       71 | Location 71  |      1 | Region 1   |        5 | District 5   
         5 |      618 | Location 618 |      1 | Region 1   |        5 | District 5   

我是用索引匹配完成的,但是它非常慢。这是screenshot

我尝试了上述方法,然后再次尝试使用表名和列名。

=INDEX(LocTable[[#Headers],[Region]], MATCH(MetricsTable[[#Headers],[Division]]&MetricsTable[[#Headers],[Location]],LocTable[[#Headers],[Division]]&LocTable[[#Headers],[Location]],0))

但是,以上方法创建了一个表数组“表中不允许使用多单元格数组公式”。是返回到非表的唯一解决方案,以便我可以运行公式并仅处理超级慢速问题,还是VBA中有选项?预先感谢!

0 个答案:

没有答案