Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sum If - How to sum for ranges meeting certain criteria | Excel Discussion (Misc queries) | |||
SumProduct meeting two criteria | Excel Worksheet Functions | |||
count occurences meeting criteria | Excel Worksheet Functions | |||
Code to delete columns meeting a condition | Excel Discussion (Misc queries) | |||
COUNTIF MEETING TWO CRITERIA eg>5 AND <10.1 | Excel Worksheet Functions |