- 帖子
- 976
- 主題
- 7
- 精華
- 0
- 積分
- 1018
- 點名
- 0
- 作業系統
- Win10
- 軟體版本
- Office 2016
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2013-4-19
- 最後登錄
- 2025-1-10
|
17#
發表於 2022-7-25 07:45
| 只看該作者
本帖最後由 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 |
|