|
在单据那里添加以下代码:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim dep As String
With Target
Pub_Row = .Row
Pub_Col = .Column
If .Count > 1 Then Exit Sub
If Pub_Row = 2 And Pub_Col = 2 Then
dep = Cells(Target.Row, Target.Column).Value
dep = "=" & dep & "项目"
With Cells(3, 2).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=dep
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.IMEMode = xlIMEModeNoControl
.ShowInput = True
.ShowError = True
End With
End If
End With
End Sub |
|