Excel' VLOOKUP',' INDEX'和' MATCH'

时间:2017-02-08 18:42:26

标签: excel indexing match vlookup

好吧所以我想知道是否可以使用INDEX + MATCH组合将数据从底部表格传递到顶部表格,并且状态会横向移动。我需要获取代码和状态,然后我可以放置Amount并将它们匹配到顶层表。任何帮助或建议表示赞赏。

Code    Description                                 ID       Alabama    Alaska  Arizona Arkansas    California  Colorado
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100                       
1A      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                       
1B      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                       
1C      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                       
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103                       
3       ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
3A      ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
3B      ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
4       ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4A      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4B      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4C      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       


Code    Description                                 ID      State       Amount              
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Alabama     $11.00              
1A      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Alaska      $206.00             
1B      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   California  $206.00             
1C      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Colorado    $1,726.00               
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103   Alabama     $346.00             
3       ANESTHESIA RECONSTRUCTION OF EYELID         00103   Arkansas    $85.00              
3A      ANESTHESIA RECONSTRUCTION OF EYELID         00103   California  $88.00              
3B      ANESTHESIA RECONSTRUCTION OF EYELID         00103   Colorado    $67.00              
4       ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alaska      $80.00              
4A      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   California  $62.00              
4B      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alaska      $78.00              
4C      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alabama     $73.00              

所以为了给出一些例子,我希望它看起来像这样。

Code    Description                                 ID       Alabama    Alaska  Arizona Arkansas    California  Colorado
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100    11.00                
1A      ANESTHESIA SALIVARY GLAND PROCEDURES        00100              206.00        
1B      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                                           206.00        
1C      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                                                      1726.00                   
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103                       
3       ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
3A      ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
3B      ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
4       ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4A      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4B      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4C      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       


Code    Description                                 ID      State       Amount              
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Alabama     $11.00              
1A      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Alaska      $206.00             
1B      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   California  $206.00             
1C      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Colorado    $1,726.00               
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103   Alabama     $346.00             
3       ANESTHESIA RECONSTRUCTION OF EYELID         00103   Arkansas    $85.00              
3A      ANESTHESIA RECONSTRUCTION OF EYELID         00103   California  $88.00              
3B      ANESTHESIA RECONSTRUCTION OF EYELID         00103   Colorado    $67.00              
4       ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alaska      $80.00              
4A      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   California  $62.00              
4B      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alaska      $78.00              
4C      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alabama     $73.00 

编辑:这与我的电子表格上的内容更接近。

Code    Description                                 ID       Alabama    Alaska  Arizona Arkansas    California  Colorado
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100    11.00                                  20.00       50.00           
1A      ANESTHESIA SALIVARY GLAND PROCEDURES        00100              206.00        
1B      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                                           206.00        
1C      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                                                      1726.00                   
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103    200.00    100.00                                  346.00 
3       ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
3A      ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
3B      ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
4       ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4A      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4B      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4C      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104 




Code    Description                                 ID      State       Amount              
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Alabama     $11.00
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100   California  $20.00  
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Colorado    $50.00          
1A      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Alaska      $206.00             
1B      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   California  $206.00             
1C      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Colorado    $1,726.00               
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103   Alabama     $200.00
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103   Colorado    $346.00 
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103   Alaska      $100.00           
3       ANESTHESIA RECONSTRUCTION OF EYELID         00103   Arkansas    $85.00              
3A      ANESTHESIA RECONSTRUCTION OF EYELID         00103   California  $88.00              
3B      ANESTHESIA RECONSTRUCTION OF EYELID         00103   Colorado    $67.00              
4       ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alaska      $80.00              
4A      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   California  $62.00              
4B      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alaska      $78.00              
4C      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alabama     $73.00  

价格可以根据国家而变化,我希望这可以做到。

1 个答案:

答案 0 :(得分:0)

这是你正在寻找的吗?就像你说的那样,它是一个INDEX MATCH,你可以横向复制每个州的状态。它会检查代码,检查顶部的状态,如果它们匹配则会带来数量(否则为空白)。

=IF(INDEX($D$17:$D$28, MATCH($A2, $A$17:$A$28, 0)) = D$1, INDEX($E$17:$E$28, MATCH($A2, $A$17:$A$28, 0)), "")

enter image description here

编辑:我看到下面列出的问题代码&国家不一定是独一无二的。我们将通过连接代码,ID和状态来强制使用唯一的ID(我假设代码,ID和State必须返回唯一的结果,否则我认为如果它可以返回2个不同的基础数据中有些可疑达!)。在第二个表上创建代码,ID和状态串联的另一列(字面意思= = CONCATENATE(A17,C17,D17) - 尽管您可能想在它们之间放置一个分隔符以便于查看,但我会使用下划线在我的截图中)。然后,在上面的列上,将您的查找更改为指向新列,并将状态与ID连接起来,如下所示:

=IFERROR(INDEX($F$17:$F$28, MATCH($A2&"_"&$C2&"_"&D$1, $E$17:$E$28, 0)), "")

除了您的数据看起来更像是:

之外,其结果与上面的屏幕截图相同

enter image description here