Find value and select the entire row

NDMDRB

Board Regular
Joined
Jun 20, 2016
Messages
158
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)
...
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,007
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
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.
 

NDMDRB

Board Regular
Joined
Jun 20, 2016
Messages
158
Office Version
  1. 2016
Platform
  1. Windows
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)
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,007
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
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
 

Watch MrExcel Video

Forum statistics

Threads
1,128,119
Messages
5,628,799
Members
416,340
Latest member
PJB1102

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