麻辣家族討論版版's Archiver

s13030029 發表於 2022-2-9 10:51

VBA 如何比對整列資料???

[size=5][color=Blue]想請問要如何比對整列資料是否有存在資料庫中[/color][/size]
[attach]34650[/attach]

samwang 發表於 2022-2-9 12:03

[b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118387&ptid=23578]1#[/url] [i]s13030029[/i] [/b]


請附上檔案和說明如何比對呈現結果,謝謝

s13030029 發表於 2022-2-9 15:02

[b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118388&ptid=23578]2#[/url] [i]samwang[/i] [/b]

可用msgbox回答存不存在就好
[attach]34651[/attach]

samwang 發表於 2022-2-9 15:42

[b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118389&ptid=23578]3#[/url] [i]s13030029[/i] [/b]

請測試看看,謝謝

Sub test()
Dim Arr, xD, T$, i&
Set xD = CreateObject("Scripting.Dictionary")
Arr = [a1].CurrentRegion
For i = 2 To UBound(Arr)
    T = Arr(i, 1) & "|" & Arr(i, 2) & "|" & Arr(i, 3) & "|" & Arr(i, 4) & Arr(i, 5)
    xD(T) = i
Next
Arr = [g1].CurrentRegion
For i = 2 To UBound(Arr)
    T = Arr(i, 1) & "|" & Arr(i, 2) & "|" & Arr(i, 3) & "|" & Arr(i, 4) & Arr(i, 5)
    If xD(T) > 0 Then MsgBox T & "存在"
Next
End Sub

s13030029 發表於 2022-2-9 16:41

[b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118390&ptid=23578]4#[/url] [i]samwang[/i] [/b]
[size=4]想再請教一下
如果存在的話,能顯示是在資料庫中的第幾列嗎?
感謝~~[/size]

samwang 發表於 2022-2-9 17:43

[quote]回復  samwang
想再請教一下
如果存在的話,能顯示是在資料庫中的第幾列嗎?
感謝~~
[size=2][color=#999999]s13030029 發表於 2022-2-9 16:41[/color] [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118392&ptid=23578][img]http://forum.twbts.com/images/common/back.gif[/img][/url][/size][/quote]


If xD(T) > 0 Then MsgBox T & ": 存在[color=Red]第[/color]" [color=Red]& xD(T) & "列"[/color]

s13030029 發表於 2022-2-10 10:25

[b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118394&ptid=23578]6#[/url] [i]samwang[/i] [/b]

原來如此~
感謝您~

頁: [1]

麻辣家族討論版版為 麻辣學園 網站成員  由 昱得資訊工作室 © Since 1993 所提供