Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8177471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:31:08+00:00 2026-06-06T23:31:08+00:00

Ok, So I have a userform in excel, and I have a textbox called

  • 0

Ok, So I have a userform in excel, and I have a textbox called “IMEITextBox” on the form. I have a inventory sheet that have IMEI numbers in Coloum B that I have in stock. When I enter an IMEI number in the IMEITextBox, I want it to delete the row containing that IMEI numbe from sheet “Inventory” when I save. I have researched this over and over for days now. Cant seem to find anything that works for me. Can you assist?

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:31:09+00:00Added an answer on June 6, 2026 at 11:31 pm

    I have commented the code so that you will not have a problem understanding it… After seeing the code, you will realize that you were very close 😉

    Option Explicit
    
    Sub DeleteRows()
        Dim ws As Worksheet
        Dim strSearch As String
        Dim aCell As Range
    
        On Error GoTo Err
    
        '~~> Set the sheet where you want to search the IMEI
        Set ws = Sheets("Inventory")
    
        With ws
            '~~> Get the value which you want to search
            strSearch = IMEITextBox.Value
    
            '~~> Column A is Column 1 so Column B is 2. This is where we are searching
            '~~> xlWhole is used in the code below so that we find a complete match
            '~~> xlPart is supposed to be used when you are finding a partial match.
            Set aCell = .Columns(2).Find(What:=strSearch, LookIn:=xlValues, _
            LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False)
    
            '~~> Check if we found the value
            If Not aCell Is Nothing Then
                '~~> get the row of the cell where we found the match and delete it
                .Rows(aCell.Row).Delete
            Else '<~~ If not found
                MsgBox "IMEI Number not Found"
            End If
        End With
    
        Exit Sub
    Err:
        MsgBox Err.Description
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UserForm with some textbox entry fields on it that are enabled/disabled
I have a textbox on a userform. If the user fails to enter anything
I have a textbox on a userform that I am trying to restrict user
I have created a Userform that lets the user pick a worksheet from a
I have a user form that is working perfectly. The page makes use of
I have added a ListBox to a SHEET (not to a UserForm) I did
I have a winforms application that includes an Administration form (call it 'adminForm') and
In excel vba I have added a commandbutton to userform... like below Set ctrl
I have an Excel2010 VBA userform that has one comboBox, from which the user
Currently, I have an Excel spreadsheet with some data and a command button that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.