Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Delete Row meeting a Criteria

Is there a way to delete a row that meets a certain criteria using VBA.

For example, my spreadsheet has 100 rows and I want to delete every row that
has the word "DUP" in it. They will be spreadout over the 100 rows.

Please let me know.

Thanks



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Delete Row meeting a Criteria

Try something like the following:

Dim RowNdx As Long
Dim LastRow As Long
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "A").Value = "DUP" Then
Rows(RowNdx).Delete
End If
Next RowNdx

This will delete all the rows that have "DUP" in column A.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"SRS Man" wrote in message
...
Is there a way to delete a row that meets a certain criteria

using VBA.

For example, my spreadsheet has 100 rows and I want to delete

every row that
has the word "DUP" in it. They will be spreadout over the 100

rows.

Please let me know.

Thanks





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Delete Row meeting a Criteria

Thanks Chip


"Chip Pearson" wrote in message
...
Try something like the following:

Dim RowNdx As Long
Dim LastRow As Long
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "A").Value = "DUP" Then
Rows(RowNdx).Delete
End If
Next RowNdx

This will delete all the rows that have "DUP" in column A.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"SRS Man" wrote in message
...
Is there a way to delete a row that meets a certain criteria

using VBA.

For example, my spreadsheet has 100 rows and I want to delete

every row that
has the word "DUP" in it. They will be spreadout over the 100

rows.

Please let me know.

Thanks







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Delete Row meeting a Criteria

Hi Man.

Sounds like "DUP" is the result of a formula looking for duplicates.
If so why not change this to 0 (zero) and sort by that column, and then delete the rows with 0?


Regards Robert

"SRS Man" wrote in message ...
Is there a way to delete a row that meets a certain criteria using VBA.

For example, my spreadsheet has 100 rows and I want to delete every row that
has the word "DUP" in it. They will be spreadout over the 100 rows.

Please let me know.

Thanks





---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004


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
Sum If - How to sum for ranges meeting certain criteria Corrina Excel Discussion (Misc queries) 1 March 23rd 10 04:44 PM
SumProduct meeting two criteria Mindy Excel Worksheet Functions 4 July 23rd 09 02:43 PM
count occurences meeting criteria geebee Excel Worksheet Functions 8 July 17th 08 05:09 PM
Code to delete columns meeting a condition CEG Excel Discussion (Misc queries) 6 February 5th 07 05:03 PM
COUNTIF MEETING TWO CRITERIA eg>5 AND <10.1 John Higgins Excel Worksheet Functions 2 December 22nd 04 01:19 AM


All times are GMT +1. The time now is 04:34 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"