excelr的 VBA 运行时错误1004"save"作用于对象"-wrokbook"时失败,求高手解决!
PrivateSubWorksheet_SelectionChange(ByValTargetAsRange)Cells.Interior.Color=xlNoneAct...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.Color = xlNone
ActiveCell().EntireRow.Interior.Color = RGB(255, 255, 160)
If Target.Address = "$B$5" Then
Dim dic As Object
Dim arr, i%
arr = Sheet4.Range("B8:B" & Sheet4.[B100000].End(3).Row)
Set dic = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
If arr(i, 1) <> "" Then dic(arr(i, 1)) = ""
Next
With Range("$B$5").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Join(dic.keys, ",")
End With
End If
If Target.Address = "$C$5" Then
arr = Sheet4.Range("A7:A" & Sheet4.[A100000].End(3).Row)
Set dic = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
If arr(i, 1) <> "" Then dic(arr(i, 1)) = ""
Next
With Range("$C$5").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Join(dic.keys, ",")
End With
End If
If Target.Address = "$D$5" Then
arr = Sheet4.Range("A7:A" & Sheet4.[A100000].End(3).Row)
Set dic = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
If arr(i, 1) <> "" Then dic(arr(i, 1)) = ""
Next
With Range("$D$5").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Join(dic.keys, ",")
End With
End If
End Sub 展开
Cells.Interior.Color = xlNone
ActiveCell().EntireRow.Interior.Color = RGB(255, 255, 160)
If Target.Address = "$B$5" Then
Dim dic As Object
Dim arr, i%
arr = Sheet4.Range("B8:B" & Sheet4.[B100000].End(3).Row)
Set dic = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
If arr(i, 1) <> "" Then dic(arr(i, 1)) = ""
Next
With Range("$B$5").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Join(dic.keys, ",")
End With
End If
If Target.Address = "$C$5" Then
arr = Sheet4.Range("A7:A" & Sheet4.[A100000].End(3).Row)
Set dic = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
If arr(i, 1) <> "" Then dic(arr(i, 1)) = ""
Next
With Range("$C$5").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Join(dic.keys, ",")
End With
End If
If Target.Address = "$D$5" Then
arr = Sheet4.Range("A7:A" & Sheet4.[A100000].End(3).Row)
Set dic = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
If arr(i, 1) <> "" Then dic(arr(i, 1)) = ""
Next
With Range("$D$5").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Join(dic.keys, ",")
End With
End If
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询