我对有条件的IF有疑问,我想知道您是否可以帮助我解决该问题。
我有两张纸;
您能否帮助我理解在条件不匹配时如何编写此宏?
Sub Update_Inventory()
Application.ScreenUpdating = False
Dim lrow As Long
Dim dstar As Double
dstar = Timer
ThisWorkbook.Activate
lrow = Worksheets("Sheet1").Cells(Worksheets("Sheet2").Rows.Count, 4).End(xlUp).Row
lrow = lrow + 1
Worksheets("Inventory").Select
***' I have tried to write a line macro IF condition
'IF ActiveSheet.Range("InventoryDetailTbl['#33]").Value = "Triage" Then***
With ActiveSheet.ListObjects("InventoryDetailTbl")
.Range.AutoFilter Field:=33, _
Criteria1:="Triage"
Union(.ListColumns(2).DataBodyRange, _
.ListColumns(3).DataBodyRange, _
.ListColumns(4).DataBodyRange, _
.ListColumns(6).DataBodyRange, _
.ListColumns(8).DataBodyRange).Copy
End With
Worksheets("Sheet1").Select
Range("D" & lrow).PasteSpecial
Else
MsgBox "There isn't new items to move"
End if
Worksheets("Inventory").Select
With ActiveSheet.ListObjects("InventoryDetailTbl")
.Range.AutoFilter Field:=33
End With
Worksheets("Sheet1").Select
Application.ScreenUpdating = True
End Sub