VBA从Worksheet中删除整行匹配

时间:2016-10-10 17:25:36

标签: vba find

我为这个完整的初学者问题道歉,但我似乎无法使标题中描述的功能正常工作。

这是我的代码:

Private Sub cmdDelete_Click()

Dim wb As Workbook
Dim wsOffice As Worksheet, wsIndusrial As Worksheet
Dim FindItem As Range

Set wb = ActiveWorkbook
Set wsOffice = wb.Worksheets("Office")
Set wsIndustrial = wb.Worksheets("Industrial")

Select Case Me.Category
    Case "Office Supplies"
        Set FindItem = wsOffice.Range("D2:D500").Find(Me.SEModelNumber)

        wsOffice.Rows(FindItem.Row).Delete

    Case "Industry Supplies"
        Set FindItem = wsIndustrial.Range("D2:D500").Find(Me.SEModelNumber)

        wsIndustrial.Rows(FindItem.Row).Delete

End Select

End Sub

我没有收到错误,但是" FindItem"永远不能在D列中找到ID。

我做错了什么?

0 个答案:

没有答案