返回列表 上一主題 發帖

[發問] 下拉選單模糊搜尋後相同名稱不同值之困惑...

回復 10# samwang

感謝您的回覆
所提供之方式有試過...筆數愈多時會造成所述繞圈圈問題

TOP

回復  samwang

感謝您的回覆
所提供之方式有試過...筆數愈多時會造成所述繞圈圈問題
cypd 發表於 2022-7-23 09:18


10樓方式是用內建,你的11樓方式是用公式,所以有可能會比較慢
請在確認看看,謝謝

TOP

回復 11# cypd

請測試看看,謝謝
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Arr, xD, C%, T$, m&, i&
If Target.Column = 3 Then C = 3
If Target.Column = 4 Then C = 4
Set xD = CreateObject("Scripting.Dictionary")
With Sheets("客戶基本資料")
    Arr = .Range(.Cells(1, C), .Cells(Rows.Count, C).End(3))
    .Range(.Cells(1, C), .Cells(Rows.Count, C).End(3)).Font.ColorIndex = 0
    .Range(.Cells(1, C), .Cells(Rows.Count, C).End(3)).Interior.ColorIndex = 0
    For i = 1 To UBound(Arr)
        T = Arr(i, 1)
        If xD.Exists(T) Then
            m = xD(T)
            Cells(m, C).Font.ColorIndex = 3
            Cells(m, C).Interior.ColorIndex = 36
            Cells(i, C).Font.ColorIndex = 3
            Cells(i, C).Interior.ColorIndex = 36
        End If
        xD(T) = i
    Next
End With
End Sub

TOP

回復 13# samwang
太感謝您了...samwang

速度方面問題已 OK
經測試另有問題出現如下
若是 C 或 D 欄出現相同數據時...刪除下列數據之後儲存格會有填滿之色彩存在 ???



TOP

回復  samwang
太感謝您了...samwang

速度方面問題已 OK
經測試另有問題出現如下
若是 C 或 D 欄出現 ...
cypd 發表於 2022-7-24 11:33


修改如下移除.End(3),請測試看看,謝謝
With Sheets("客戶基本資料")
    Arr = .Range(.Cells(1, C), .Cells(Rows.Count, C).End(3))
    .Range(.Cells(1, C), .Cells(Rows.Count, C)).Font.ColorIndex = 0
    .Range(.Cells(1, C), .Cells(Rows.Count, C)).Interior.ColorIndex = 0

TOP

回復 15# samwang

太感謝您了...samwang

C 或 D 欄出現相同數據時...刪除下列數據之後儲存格會有填滿之色彩存在(已解決所述問題  ^^)



該工作表因有相關之公式運算,為確保誤刪造成資料錯誤...設有  [保護工作表]
因保護工作表之關係造成...執行階段錯誤 "1004"
再度麻煩您修正...感恩  ^^

TOP

本帖最後由 samwang 於 2022-7-25 07:47 編輯
回復  samwang

太感謝您了...samwang

C 或 D 欄出現相同數據時...刪除下列數據之後儲存格會有填滿之 ...
cypd 發表於 2022-7-24 20:23


請測試看看,謝謝
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Arr, xD, C%, T$, m&, i&
If Target.Column = 3 Then C = 3
If Target.Column = 4 Then C = 4
If C = 0 Then Exit Sub
Set xD = CreateObject("Scripting.Dictionary")
With Sheets("客戶基本資料")
    .Unprotect Password:="1234"  '解保護,密碼自行修改
     Arr = .Range(.Cells(1, C), .Cells(Rows.Count, C).End(3))
     .Range(.Cells(1, C), .Cells(Rows.Count, C)).Font.ColorIndex = 0
     .Range(.Cells(1, C), .Cells(Rows.Count, C)).Interior.ColorIndex = 0
     For i = 1 To UBound(Arr)
         T = Arr(i, 1)
         If xD.Exists(T) Then
             m = xD(T)
             .Cells(m, C).Font.ColorIndex = 3
             .Cells(m, C).Interior.ColorIndex = 36
             .Cells(i, C).Font.ColorIndex = 3
             .Cells(i, C).Interior.ColorIndex = 36
         End If
         xD(T) = i
     Next
    .Unprotect Password:="1234"  '保護,密碼自行修改
End With
End Sub

TOP

回復 17# samwang

太神了感謝您了...samwang
所遇之問題瓶頸大致已獲得解決…^^感恩
另外
.Unprotect Password:="1234"  '保護,密碼自行修改(多了 Un 無法進行保護)
已刪除 Un…測試 OK

TOP

回復 18# cypd

另外
.Unprotect Password:="1234"  '保護,密碼自行修改(多了 Un 無法進行保護)
已刪除 Un…測試 OK

>> 不好意思,沒有更新到,如您修改UN要刪除,謝謝

TOP

本帖最後由 cypd 於 2022-7-26 15:16 編輯

回復 19# samwang

煩問  samwang...
關於上述 VBA 作動之後所產生相關疑問 ?

VBA公式作動後
若 C 欄有新數據輸入時會造成 C1 底色不見
若 D 欄有新數據輸入時會造成 D1 底色不見

原保護工作表內之設定失效
(自行設定列格式及使用自動篩選無法使用...恢復預設值)




0726.rar (147.23 KB)

TOP

        靜思自在 : 原諒別人就是善待自己。
返回列表 上一主題