- 帖子
- 122
- 主題
- 26
- 精華
- 0
- 積分
- 148
- 點名
- 0
- 作業系統
- windos10
- 軟體版本
- office2016
- 閱讀權限
- 20
- 註冊時間
- 2021-7-8
- 最後登錄
- 2023-8-28
|
回復 17# cowww
我把語法改成這樣
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Target
Dim xR As Range, xA As Range, xB As Range
If .Columns.Count = Columns.CountLarge Then Exit Sub
If .Count > 1 Or .Column = 1 Or .Row < 5 Then Exit Sub
Set xR = .Cells: Set xA = Range([B1], Cells(1, Columns.Count)).EntireColumn
Set xB = Range([A5], Cells(Rows.Count, 1)).EntireRow
With Intersect(ActiveSheet.UsedRange, xA, xB)
.Interior.ColorIndex = xlNone
If Range("F2") = "N" Then
Intersect(xR.EntireRow, .Cells).Interior.ColorIndex = 0
Intersect(xR.EntireColumn, .Cells).Interior.ColorIndex = 0
.Interior.ColorIndex = 0
Else
Intersect(xR.EntireRow, .Cells).Interior.ColorIndex = 6
Intersect(xR.EntireColumn, .Cells).Interior.ColorIndex = 6
End If
End With
.Interior.ColorIndex = 4
End With
End Sub
變色選擇"YES"
變色選擇"NO"
有辦法把"NO"的單元個底色變成 無色 嗎? |
|