1
我有兩個電子表格,其中一個包含我需要清理(命名爲「fedex」)的數據,方法是刪除一些與另一電子表格(名爲「sheet1」)中的數字列表匹配的行。 電子表格「fedex」列「H」具有與電子表格「sheet1」列「A」匹配的數字。如何刪除與其他工作表中的條件匹配的行?
我得到一個類型不匹配錯誤消息,當它到達set lastrow = fedex.cells(Rows.count,8)end(xlUp).Row
我不知道如果代碼的其餘部分將工作,因爲我被困在那裏。
這是我的代碼:
Sub deletepaidshipments()
Dim fedex As Worksheet
Set fedex = ThisWorkbook.Sheets("fedex_shipment_detail_payer_det")
Dim sheet1 As Worksheet
Set sheet1 = ThisWorkbook.Sheets("sheet1")
Set lastrow = fedex.Cells(Rows.Count, 8).End(xlUp).Row
For x = 2 To lastrow
t = 0
On Error Resume Next
t = Application.WorksheetFunction.Match(fedex.Range("h" & x), sheet1.Range("a :a"), 0)
On Error GoTo 0
If t > 0 Then
fedex.Rows(x, lastrow).Delete
End If
Next x
End Sub
'設置LASTROW = fedex.Cells(Rows.Count,8) .End(xlUp).Row'應該是'lastrow = fedex.Cells(fedex.Rows.Count,8).End(xlUp).Row' –
它沒有工作......我得到相同的錯誤信息.. – DHI