find and delete row from certain value

SimpleSimon88

New Member
Joined
Jan 15, 2014
Messages
19
Hi, I'm struggling to find how to find a value in a range and delete that row.

Example:
search("textbox1.value"),sheets("sheet1").Range("A1:A5000").delete

Any ideas?

Si
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

DILIPandey

Well-known Member
Joined
Jul 25, 2013
Messages
1,336
Hi Si,

What type of text box you are using here ?
form control or activex ?


Regards,
DILIPandey
 
Upvote 0

DILIPandey

Well-known Member
Joined
Jul 25, 2013
Messages
1,336
Anyways, give below code a try:-

Range("a1:a5000").Replace What:=Sheets("Sheet1").TextBox1.Text, Replacement:=""

Regards,
DILIPandey
 
Upvote 0

SimpleSimon88

New Member
Joined
Jan 15, 2014
Messages
19
Hi fella!
Its a userform textbox and (preferably) would like to delete entire row.
I've found a basic loop but not really confident with loops yet.
It's userform1.textbox1.value

Si
 
Upvote 0

DILIPandey

Well-known Member
Joined
Jul 25, 2013
Messages
1,336
Dear Si,

You can use below code:-

Code:
Sub DILIPandey()
'checking and deleting rows based on a textbox's value
    For Each cell In Range("a1:a500")
        cell.Select
        If cell.Value = Sheets("Sheet1").TextBox1.Text Then
            ActiveCell.EntireRow.Delete
        End If
    Next
End Sub

where you can replace Sheets("Sheet1").TextBox1.Text with your userform's value


Regards,
DILIPandey
 
Upvote 0

Forum statistics

Threads
1,196,007
Messages
6,012,831
Members
441,732
Latest member
Ayon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top