Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ...
准提部林 發表於 2024-2-3 10:35
其實是小的把欄位搞錯了
真的是非常抱歉
實際上應該是
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xA As Range, xB As Range, X As Range, R&
Set xA = [AR212:AR219,AX212:AX219]
Set xB = [AG212:AG219]
With Target
If xB.FormatConditions.Count Then xB.FormatConditions.Delete
If .Count > 1 Then Exit Sub
Set X = Intersect(.Cells, xA)
If X Is Nothing Then Exit Sub
R = X.Row - xA.Item(1).Row + 1
With xB.Item(R).FormatConditions
.Add Type:=xlCellValue, Operator:=xlNotEqual, Formula1:="=""^_^"""
.Item(1).Interior.ColorIndex = 6
End With
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xA As Range, xB As Range, X As Range, R&
Set xA = [AR212:AR219,AX212:AX219]
Set xB = [AF212:AF219,AG212:AG219]
With Target
If xB.FormatConditions.Count Then xB.FormatConditions.Delete
If .Count > 1 Then Exit Sub
Set X = Intersect(.Cells, xA)
If X Is Nothing Then Exit Sub
R = X.Row - xA.Item(1).Row + 1
With xB.Item(R).FormatConditions
.Add Type:=xlCellValue, Operator:=xlNotEqual, Formula1:="=""^_^"""
.Item(1).Interior.ColorIndex = 6
End With
End With
End Sub