这里是新功能,我目前正在学习VBA。我有一个同事,他最近创建了一个与我正在做的项目类似的项目,我在工作簿中引用他的代码以执行相同的操作。唯一的麻烦是我遇到此错误:
Dim partSearch As Range
Dim partFind As Variant
Dim partTotal As Variant
Dim partLoc As Variant
Dim partColor As Variant
Application.ScreenUpdating = False
Sheets("Import").Select
Range("C2").Activate
partFind = ActiveCell.Value
Sheets("2019").Select
Rows("28:28").Select
Selection.AutoFilter
Range("A2").Select
Set partSearch = Cells.Find(What:=partFind, After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not partSearch Is Nothing Then
Cells.Find(What:=partFind, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
partColor = Cells(24, (ActiveCell.Column)).Value
Range("BM" & (ActiveCell.Row)).Select
Do
partTotal = ActiveCell.Value
If partTotal = "X" Or partTotal = "x" Then
Cells(28, (ActiveCell.Column)).Select
partLoc = ActiveCell.Value
ActiveSheet.Range("$A$28:$PB$535").AutoFilter Field:=partLoc,
Criteria1:="
ActiveSheet.Range("$A$28:$PB$535").AutoFilter Field:=24,
Criteria1:="="`
Else
ActiveCell.Offset(0, 1).Activate
End If
错误在这里发生:
ActiveSheet.Range("$A$28:$PB$535").AutoFilter Field:=partLoc, Criteria1:="<>"
ActiveSheet.Range("$A$28:$PB$535").AutoFilter Field:=24,
Criteria1:="="`
Else
ActiveCell.Offset(0, 1).Activate
End If