excel~我想讓經過條件篩選,讓B檔案的某欄=A檔案的某欄

EX

如果
A檔案的A1=B檔案的A1:A100中的某值
A檔案的B1=B檔案的B1:100中的某值
A檔案的C1=B檔案的C1:100中的某值

那麼
A檔案的D1=B檔案的D1:100中的某值


不知道這樣問問題,夠清楚嗎?

請先進不吝指導...
謝謝...
2016-05-14 14:34 發佈
可能要分段處理

a-chin65 wrote:
EX如果A檔案的A1...(恕刪)
a-chin65 wrote:
不知道這樣問問題,夠清楚嗎?


可否利用下圖(B 檔案資料)以圖解或舉例方式將問題解說的更清楚!

My Interior Knowledge is Extraordinaire
1.自訂一函數:getmatchvalue

Function getMatchValue(ByVal table_Array As Range, ByVal col_Index_Num As Integer, _
ByVal lookup_Value1 As Variant, ByVal lookup_Col_index_Num1 As Integer, _
Optional ByVal lookup_Value2 As Variant, Optional ByVal lookup_Col_index_Num2 As Integer, _
Optional ByVal lookup_Value3 As Variant, Optional ByVal lookup_Col_index_Num3 As Integer) As Variant

Dim i, j As Integer
Dim rng, items
Dim hasKey2, hasKey3 As Boolean

hasKey2 = Not IsMissing(lookup_Value2) And Not IsError(lookup_Value2)
hasKey3 = Not IsMissing(lookup_Value3) And Not IsError(lookup_Value3)

ReDim items(499) As Variant
i = 0
items(i) = Empty

For Each rng In table_Array.Offset(0, lookup_Col_index_Num1 - 1).Resize(table_Array.Rows.Count, 1)
If rng.Value = lookup_Value1 Then
If Not hasKey2 Then
GoSub collectItem
Else
If rng.Offset(0, lookup_Col_index_Num2 - lookup_Col_index_Num1).Value = lookup_Value2 Then
If Not hasKey3 Then
GoSub collectItem
Else
If rng.Offset(0, lookup_Col_index_Num3 - lookup_Col_index_Num1).Value = lookup_Value3 Then
GoSub collectItem
End If
end if
end if
End If
End If
Next

If Not IsNull(items(0)) And Len(items(0)) > 0 Then
getMatchValue = items
GoSub returnAsLines
Else
getMatchValue = Empty
End If

Exit Function

returnAsLines:
Dim ln As String

ln = ""
For j = 0 To i - 1
ln = ln & items(j) & Chr(10)
Next
If Len(ln) > 1 Then getMatchValue = Left(ln, Len(ln) - 1)
Return

collectItem:
items(i) = rng.Offset(0, col_Index_Num - lookup_Col_index_Num1).Value
i = i + 1
Return

End Function

2.在工作表上的D欄位,輸入公式:
=getmatchvalue([refer.xlsx]工作表1!A$1:D$9,4,B161,1,C161,2,D161,3)

a.refer.xlsx 也就是B表
b.4 表示傳回 Refer.xlsx 的工作表1 的第四欄(D)的值
c.B161,C161,D161 代表查找值所在格, 1,2,3 分別代表Refer.xlsx 的工作表1 上的第一欄、第二欄、第三欄



嗯~理論上Vlookup 這個只能用在檢驗一種條件下符合~就帶出結果,你有3種條件。

所以解決方式就是 把3種條件變成一種條件比較快~

方法就是 分別在二個檔案新增一欄 ,然後公式是這樣 =A1&B1&C1

這樣新的一欄的值就會是 三個條件堆疊起來的,然後用新的這個去作vlookup

這方式可以解決大部份的狀況,但還是有少部份不適合這樣作,那就要用ACCESS 來作比較OK! ACCESS就不教囉!
建議用if加countif

if(countif(A1:A100,A1)=0 表示找不到

先作驗證完,再看後面要作什麼公式處理
如果countif結果是有數值(不等於0)
D那欄就可以用Vlookup去找,不過好像沒有索引欄?


a-chin65 wrote:
EX如果A檔案的A1...(恕刪)
內文搜尋
X
評分
評分
複製連結
Mobile01提醒您
您目前瀏覽的是行動版網頁
是否切換到電腦版網頁呢?