簡體   English   中英

根據另一個單元格的值,使用列表中的值填充幾個單元格

[英]Populate several cells with values from list based on value of another cell

我正在尋找報告方面的幫助。 在“ sheet1”上,我具有以下格式的區域列表和相應的醫院:

A              B             C             D              E          
1 Regions     Region 1      Region 2      Region 3       Region 4
2 Region 1    Hospital 1    Hospital 6    Hospital 11    Hospital 15
3 Region 2    Hospital 2    Hospital 7    Hospital 12    Hospital 16
4 Region 3    Hospital 3    Hospital 8    Hospital 13    Hospital 17
5 Region 4    Hospital 4    Hospital 9    Hospital 14    Hospital 18
6 Region 5    Hospital 5    Hospital 10
7 Region 6
8 Region 7
9 Region 8

在我的“報告”表上,我設置了下表,其中A6列標題為“ Region”,B6列標題為“ Hospital”:

A              B            C            D            E
6   Region         Hospital
7   Region 1       Hospital 1
8                               
9
10
11                 Hospital 2
12
13
14
15                 Hospital 3
16
17
18
19                 Hospital 4
20
21
22
23                 Hospital 5
24

我想做的是:從“報告”表的A7中的列表中選擇“區域1”后,我希望B7,B11,B15,B19和B23填充列標題中的值“ sheet1”的“區域1”(B列)。

作為一個額外的復雜性,我需要動態的解決方案,因為當我將醫院添加到“ sheet1”中“區域”列中的一個時,該醫院也將結轉到“在A7中選擇該區域時生成“報告”表。 報告表中的每個“醫院”之間都有3個單元格。

嘗試此公式並將其放到B7,它將從列表中獲得第一家醫院。 sheet2是您的報告表。 在3個單元格之后再次放置該公式將使該區域的其余部分受益。 盡管您必須在每3個單元格之后手動放置公式,才能使用公式使其動態化。

=IF($A$7=Sheet1!$B$1,IF(Sheet1!B2<>"",Sheet1!B2,""))

注意:復制到其他單元格時,將B2加1,例如,將公式放到下一個要成為B11的單元格時,Sheet1!B2應該變成Sheet1!B3,就像這樣

=IF($A$7=Sheet1!$B$1,IF(Sheet1!B3<>"",Sheet1!B3,""))

對要復制此公式的其余單元格執行相同的過程

另外:您說這只能解決部分問題,所以我對其進行了修訂。 嘗試使用這個。

=IF($A$7="r1",Sheet1!B2,IF($A$7="r2",Sheet1!C2,IF($A$7="r3",Sheet1!D2,IF($A$7="r4",Sheet1!E2,""))))

注意:您看到的r1至r4是您所在區域的名稱。 只需將它們替換為Region 1,以此類推。

使用VLOOKUP函數:

VLOOKUP(A7,Hospital!:$A$1:$E$9,2)

A7 = The value to match

<br>Hospital! = Sheet where the lookup table exists
<br>:$A$1 = The starting cell for the table (top left corner)
<br>:$E$9 = The end cell (bottom right corner)
<br>2 = the corresponding value you want to display

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM