VBA错误:对象variables或未设置块variables

我是VBA新手,正在处理一个macros,它将删除材料跟踪电子表格中的重复行,它们是基于标签为“Requisition Number”,“Item”和“PO#”的3个特定列中的匹配元素。

但是,当我尝试设置使用ActiveSheet.Range(Cells(1, colReq.Column).Address()).Activate我的申请单号中的第一个元素ActiveSheet.Range(Cells(1, colReq.Column).Address()).Activate我给出的错误:对象variables或块variables未设置

以下是我的完整代码:

 Sub DeleteDuplicates() Dim sh As Worksheet Set sh = ThisWorkbook.Sheets("Sheet1") Dim lastRow As Long lastRow = sh.Range("A1", sh.Range("A1").End(xlDown)).Rows.Count Dim colReq As Range Dim colItemReq As Range Dim colPO As Range Dim colType As Range With ActiveSheet.UsedRange.Rows(1) Set colReq = .Find(What:="Requisition Number", LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False) Set colItemReq = .Find(What:="Item", LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False) Set colPO = .Find(What:="PO #", LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False) Set colType = .Find(What:="PO #", LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False) End With Dim current As String ActiveSheet.Range(Cells(1, colReq.Column).Address()).Activate Do While ActiveCell.Value <> "" current = ActiveCell.Address ActiveCell.Offset(1, 0).Activate Do While ActiveCell.Value <> "" If (ActiveSheet.Range(current).Value = ActiveCell.Value) And _ ((ActiveSheet.Range(Cells(ActiveCell.Row - 1, colItemReq.Column).Address).Value) = ActiveSheet.Range(Cells(ActiveCell.Row, colItemNumber).Value)) And _ ((ActiveSheet.Range(Cells(ActiveCell.Row - 1, colPO).Address).Value) = ActiveSheet.Range(Cells(ActiveCell.Row, colPO).Value)) And (ActiveCell.Value <> "Shipping Notification") Then ActiveSheet.Rows(ActiveCell.Row).Delete Else ActiveCell.Offset(1, 0).Activate End If Loop ActiveSheet.Range(current).Offset(1, 0).Activate Loop End Sub