|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
代码放Sheet2中:
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- If Target.Address <> "$L$1" Then Exit Sub
- Dim i%, j%, d, k, arr
- Set d = CreateObject("scripting.dictionary")
- With Sheets("Sheet2")
- arr = Range("B2:K" & .Cells(.Rows.Count, 2).End(xlUp).Row).Value
- For i = 2 To UBound(arr) Step 2
- For j = 1 To UBound(arr, 2)
- d(arr(i, j)) = ""
- Next
- Next
- k = d.keys
- With .[L1].Validation
- .Delete
- .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=Join(k, ",")
- End With
- End With
- d.RemoveAll
- End Sub
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Target.Address <> "$L$1" Then Exit Sub
- With Sheets("Sheet2")
- Dim rng As Range
- .Range("B2:K" & .Cells(.Rows.Count, 2).End(xlUp).Row).Interior.ColorIndex = xlNone
- .Range("B2:K" & .Cells(.Rows.Count, 2).End(xlUp).Row).Font.ColorIndex = xlAutomatic
- With Sheets("Sheet1")
- .Range("B2:K" & .Cells(.Rows.Count, 2).End(xlUp).Row).Interior.ColorIndex = xlNone
- .Range("B2:K" & .Cells(.Rows.Count, 2).End(xlUp).Row).Font.ColorIndex = xlAutomatic
- End With
- For Each rng In .Range("B2:K" & .Cells(.Rows.Count, 2).End(xlUp).Row)
- If rng.Value = .[L1].Value Then
- rng.Interior.ColorIndex = 3
- rng.Font.ColorIndex = 6
- With Sheets("Sheet1")
- .Cells((rng.Row - 1) / 2 + 1, rng.Column).Interior.ColorIndex = 3
- .Cells((rng.Row - 1) / 2 + 1, rng.Column).Font.ColorIndex = 6
- End With
- End If
- Next
- End With
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|