我的vba在下面,可能会在申请一些订单时发生冲突:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
Dim c As Range
For Each c In Range("J11:J24")
If c.Value = 0 Then
Range(Cells(c.Row, "N"), Cells(c.Row, "U")).ClearContents
End If
Next c
Application.EnableEvents = True
If Intersect(Target, Range(Cells(11, Target.Column), Cells(48, Target.Column))) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
If WorksheetFunction.CountIf(Range(Cells(11, Target.Column), Cells(48, Target.Column)), Target) > 1 Then
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
MsgBox "DUBLICATED PLEASE DEFINE ANOTHER!"
End If
End Sub
当删除范围内的源单元格时,第1个事件清除相邻单元格的内容,第2个事件检查整个表格中的相关单元格。如果我先删除单元格然后检查出版物我收到了错误但如果我检查出版物然后删除单元格没有错误发生。我试图交换vba字符串,但没有恢复。提前感谢您的帮助。