|
求助 下标越界 提示卡在背景色这行。到底是什么原因呢
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Selection.Count > 1 Then Exit Sub
Dim i&, j&, r&, arr
r = Target.Row
j = Target.Column
If Sheets("数据库").Range("q" & r) = "" Then Exit Sub
If Sheets("数据库").Range("b" & r) <> "喷绘" And Sheets("数据库").Range("b" & r) <> "*出货" Then Exit Sub
xrow = Sheets("生产计划表").Range("b65536").End(3).Row
If r = 1 Then Exit Sub
If j <> 12 Then Exit Sub
Set d = CreateObject("Scripting.Dictionary")
arr = Sheets("生产计划表").Range("a1:t" & xrow)
For i = 2 To UBound(arr)
If Sheets("数据库").Range("b" & r) = "*出货" And Sheets("生产计划表").arr(i, 20) = Sheets("数据库").Range("q" & r) And Sheets("生产计划表").arr(i, 18) - Sheets("生产计划表").arr(i, 19) > 0 Then
Sheets("生产计划表").d(arr(i, 1)) = ""
ElseIf Sheets("数据库").Range("b" & r) = "喷绘" And Sheets("生产计划表").arr(i, 20) = Sheets("数据库").Range("q" & r) Then
Sheets("生产计划表").d(arr(i, 1)) = ""
End If
Next
With Sheets("数据库").Range("l" & r).Validation
.Delete
.Add 3, 1, 1, Join(d.keys, ",")
End With
Application.SendKeys "%{down}"
End Sub
|
|