Find value and select the entire row

NDMDRB

Board Regular
Joined
Jun 20, 2016
Messages
164
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have a userform using a lot of textboxes and I need to check the value in the textbox "AJE_TXT" if exist in column C or not
If exist, I need to select the entire row that contains the found text
Example, If I'm searching for number "12345" and we found it in Cell "C122", I need to select the row 122 and delete it (using .Delete Shift:=xlUp)

Set f = ws.Range("C:C").Find(What:=Me.AJE_TXT.value)
...
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
VBA Code:
Set f = ws.Range("C:C").Find(What:=Me.AJE_TXT.value) 
Rows(f.row).Delete
Although it always makes me concerned when I see only one criteria of Find being used.
 
Upvote 0
VBA Code:
Set f = ws.Range("C:C").Find(What:=Me.AJE_TXT.value)
Rows(f.row).Delete
Although it always makes me concerned when I see only one criteria of Find being used.
Thank you so much MARK858,
No actually I'm using find we many criteria as below, but just mentioned one in my post

Set f = ws.Range("C:C").Find(What:=Me.AJE_TXT.value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False)
 
Upvote 0
Then just in case the value doesn't exist then
VBA Code:
Set f = ws.Range("C:C").Find(What:=Me.AJE_TXT.value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False)
If Not f is Nothing Then
  Rows(f.Row).Delete
End If
 
Upvote 0

Forum statistics

Threads
1,214,391
Messages
6,119,239
Members
448,879
Latest member
VanGirl

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
Back
Top