excel數據庫設定

2015-06-30 11:19 pm
簡單說明及提供資料,請高手們協助

sheet1中C與D欄為資料庫,持有不相同的編號,在I及J欄需顯示C、D欄的單號,必須是相同,或有可能2個都不同

例如:
C1 ; D1
20858777 40631005



sheet2中C欄為單號,當在G欄中填寫sheet1,C與D的編號時,會自動判斷合適的資料並在sheet 1內的I及J欄顯示 單號

例如:

C1與C2是單號 G1與G2為編號
C1.123 G1.20858777
C2.123 G2.40631005

SHEET1將會是

C1 ; D1 ;I1 ; J1
20858777 40631005 123 ;123

那應對單號123,將自動顯示在I1同J1的位置.如G2編號出現在其他單號,I與J應如何顯示好

回答 (1)

2015-07-03 9:25 pm
✔ 最佳答案
假設sheet2的C欄及G欄有100列資料,I1的公式為:
=IF(ISNA(MATCH(C1,Sheet2!$G$1:$G$100,0)),"",INDEX(Sheet2!$C$1:$C$100,MATCH(C1,Sheet2!$G$1:$G$100,0)))
J1的公式為:
=IF(ISNA(MATCH(D1,Sheet2!$G$1:$G$100,0)),"",INDEX(Sheet2!$C$1:$C$100,MATCH(D1,Sheet2!$G$1:$G$100,0)))

如果只當I與J行的單號相同才顯示出來,I1或 J1的公式為:
=IF(OR(ISNA(MATCH(C1,Sheet2!$G$1:$G$100,0)),ISNA(MATCH(D1,Sheet2!$G$1:$G$100,0))),"",IF(INDEX(Sheet2!$C$1:$C$100,MATCH(C1,Sheet2!$G$1:$G$100,0))=INDEX(Sheet2!$C$1:$C$100,MATCH(D1,Sheet2!$G$1:$G$100,0)),INDEX(Sheet2!$C$1:$C$100,MATCH(C1,Sheet2!$G$1:$G$100,0)),""))

如G2編號出現在其他單號(即出現兩次或以上),可考慮加入兩行提示行在K和L,K1的公式為:
=IF(ISNUMBER(C1),IF(COUNTIF(Sheet2!$G$1:$G$100,C1)>1,"單號"&C1&"出現了"&COUNTIF(Sheet2!$G$1:$G$100,C1)&"次",""),"")
L1的公式為:
=IF(ISNUMBER(D1),IF(COUNTIF(Sheet2!$G$1:$G$100,D1)>1,"單號"&D1&"出現了"&COUNTIF(Sheet2!$G$1:$G$100,D1)&"次",""),"")
亦可簡化將兩行提示行合併成一行在K,K1的公式為:
=IF(ISNUMBER(C1),IF(COUNTIF(Sheet2!$G$1:$G$100,C1)>1,"單號"&C1&"出現了"&COUNTIF(Sheet2!$G$1:$G$100,C1)&"次",""),"")& IF(AND(ISNUMBER(C1), ISNUMBER(D1)), IF(AND(COUNTIF(Sheet2!$G$1:$G$100,C1)>1, COUNTIF(Sheet2!$G$1:$G$100,D1)>1),", ","") ,"")&IF(ISNUMBER(D1),IF(COUNTIF(Sheet2!$G$1:$G$100,D1)>1,"單號"&D1&"出現了"&COUNTIF(Sheet2!$G$1:$G$100,D1)&"次",""),"")


收錄日期: 2021-04-11 21:09:13
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20150630000051KK00041

檢視 Wayback Machine 備份