Create a macro to find value then delete it

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to create a macro that when the user clicks a button on userform1
it will find a value in sheet1 row b based on the textbox value on
userform1, when it finds the value I want it to delete then entire row. I
have tried but I cannot figure out how to make it do it
 
In the OnClick event of your button, do something like this (modify to
suite):
Dim fRow As Long
On Error GoTo ender
fRow = Columns(2).Find(What:=txt1.Value, _
After:=Cells(1, 2), LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False).Row
Rows(fRow).Delete
Exit Sub
ender:
MsgBox "Value not found"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top