A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Delete Rows using Wildcard



 
 
Thread Tools Display Modes
  #1  
Old March 16th, 2010, 02:45 PM posted to microsoft.public.excel.worksheet.functions
Max2073
external usenet poster
 
Posts: 28
Default Delete Rows using Wildcard

I'm trying to make delete all rows that DO NOT contain the text "Enter" in
column F. I need to use a wildcard - as a number of cells contain additional
data.

I have tried a few different methods based upon research from this site, but
I'm am struggling to change the following, to delete rows that DO NOT
contain the required text.

For i = 672 To 1 Step -1
If Cells(i, "J") Like "*Enter*" Then Rows(i & ":" & i).Delete
Next i


  #2  
Old March 16th, 2010, 02:51 PM posted to microsoft.public.excel.worksheet.functions
Jacob Skaria
external usenet poster
 
Posts: 5,952
Default Delete Rows using Wildcard

Try

Sub MyMacro()
Dim lngRow As Long
For lngRow = Cells(Rows.Count, "F").End(xlUp).Row To 1 Step -1
If Not Range("F" & lngRow) Like "*Enter*" Then
Rows(lngRow).Delete
End If
Next
End Sub


--
Jacob


"Max2073" wrote:

I'm trying to make delete all rows that DO NOT contain the text "Enter" in
column F. I need to use a wildcard - as a number of cells contain additional
data.

I have tried a few different methods based upon research from this site, but
I'm am struggling to change the following, to delete rows that DO NOT
contain the required text.

For i = 672 To 1 Step -1
If Cells(i, "J") Like "*Enter*" Then Rows(i & ":" & i).Delete
Next i


  #3  
Old March 16th, 2010, 02:53 PM posted to microsoft.public.excel.worksheet.functions
Luke M[_4_]
external usenet poster
 
Posts: 451
Default Delete Rows using Wildcard

For i = 672 To 1 Step -1
'Added the UCase argument to eliminate case-sensitivity
If Not (UCase(Cells(i, "J").Value) Like "*ENTER*") Then
Rows(i).EntireRow.Delete
End If
Next i

--
Best Regards,

Luke M
"Max2073" wrote in message
...
I'm trying to make delete all rows that DO NOT contain the text "Enter" in
column F. I need to use a wildcard - as a number of cells contain
additional
data.

I have tried a few different methods based upon research from this site,
but
I'm am struggling to change the following, to delete rows that DO NOT
contain the required text.

For i = 672 To 1 Step -1
If Cells(i, "J") Like "*Enter*" Then Rows(i & ":" & i).Delete
Next i




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:31 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.