Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Macro Help / Question

I have a macro that deletes the entire row if it matches certain criteria.
What I need help with is I need to delete rows that DO NOT MATCH specfic
criteria. Instead of "Like" I need a "not like" or similar. I want to delete
the row if it does not contain 591119.

T.I.A.
Ed


Sub DeleteRow2()
Dim LastRow As Long
Dim i As Long
LastRow = Range("A6536").End(xlUp).Row
For i = LastRow To 1 Step -1

If Range("S" & i).Value Like "VIP CHRG" Then
Range("S" & i).EntireRow.Delete
End If
Next 'i

For i = LastRow To 1 Step -1
If Range("S" & i).Value Like "EXCHANGE" Then
Range("S" & i).EntireRow.Delete
End If
Next 'i

End Sub





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Help / Question

Add NOT

If Not Range("S" & i).Value Like "VIP CHRG" Then



If Not Range("S" & i).Value Like "EXCHANGE" Then


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro Help / Question

if instr(1,Range("S" & i).Text,"591119",vbTextCompare) = 0 then
Range("S" & i).entireRow.Delete
End if

--
Regards,
Tom Ogilvy


Ed wrote in message
...
I have a macro that deletes the entire row if it matches certain criteria.
What I need help with is I need to delete rows that DO NOT MATCH specfic
criteria. Instead of "Like" I need a "not like" or similar. I want to

delete
the row if it does not contain 591119.

T.I.A.
Ed


Sub DeleteRow2()
Dim LastRow As Long
Dim i As Long
LastRow = Range("A6536").End(xlUp).Row
For i = LastRow To 1 Step -1

If Range("S" & i).Value Like "VIP CHRG" Then
Range("S" & i).EntireRow.Delete
End If
Next 'i

For i = LastRow To 1 Step -1
If Range("S" & i).Value Like "EXCHANGE" Then
Range("S" & i).EntireRow.Delete
End If
Next 'i

End Sub







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
Macro question orquidea Excel Worksheet Functions 10 February 6th 08 05:44 PM
Macro Question carl Excel Worksheet Functions 2 May 15th 07 07:23 PM
MACRO QUESTION Eddy Stan Excel Worksheet Functions 2 February 28th 06 01:08 PM
Macro Question sony654 Excel Worksheet Functions 3 February 27th 06 09:55 PM


All times are GMT +1. The time now is 11:36 AM.

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

About Us

"It's about Microsoft Excel"