|
你- Private Sub Workbook_Open()
- Dim Myr&, i&
- Set d = CreateObject("Scripting.Dictionary")
- Myr = Sheet35.[AB65536].End(xlUp).Row
- Arr = Sheet35.Range("AB5:Ac" & Myr)
- For i = 2 To UBound(Arr)
- d(Arr(i, 1)) = Arr(i, 2)
- Next
- End Sub
- Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
- If InStr(Sh.Name, "月") Then
- If Target.Column <> 3 Or Target.Row < 2 Then Exit Sub
- Target.Offset(0, 1) = d(Target.Value)
- End If
- End Sub
- Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
- If InStr(Sh.Name, "月") Then
- If Target.Column <> 3 Or Target.Row < 2 Then Exit Sub
- With Target.Validation
- .Delete
- .Add 3, 1, 1, Join(d.keys, ",")
- End With
- End If
- End Sub
复制代码 的工作簿不需要用文本框方式了,直接用数据有效性即可。 |
|