好的,所以我在 excel 中有一个用户表单,并且表单上有一个名为“IMEITextBox”的文本框。我有一张库存表,在 Coloum B 中有 IMEI 编号,我有库存。当我在 IMEITextBox 中输入 IMEI 号码时,我希望它在保存时从工作表“库存”中删除包含该 IMEI 号码的行。我已经研究了好几天了。似乎找不到任何对我有用的东西。你能帮忙吗?
Sub DeleteRows(IMEI)
Dim ws As Worksheet
Dim lastRow As Long, i As Long
Dim strSearch As String
Dim aCell As Range
On Error GoTo Err
Set ws = Sheets("Inventory")
lastRow = ws.Range("IMEIRange" & Rows.Count).End(xlUp).Row
strSearch = IMEITextBox.Value
Set aCell = ws.Range("IMEIRange" & lastRow).Find(What:=strSearch, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not aCell Is Nothing Then
ws.Rows(lastRow).Delete
End If
Exit Sub
Err:
MsgBox Err.Description
End Sub