Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default How to Delete rows in a column

I have the following data in Columns A and B. I would like to write code for
all rows in columns A and B that:

delete the rows for Example1 since the values in Column B are the same
delete the row for Example 2 since it only has one value
keep the rows for Example 3 since the values in Column B are NOT unique
delete the rows for Example 4 since the value in Column B are the same

Column A ColumnB
Example1 Create PO
Example1 Create PO
Example1 Create PO
Example2 Create PO
Example3 Approve Invoices
Example3 Approve Invoices
Example3 Create PO
Example4 Approve Invoices
Example4 Approve Invoices


Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default How to Delete rows in a column

One possible implementation would be to do as follows:

(It assumes that you've sorted by Column A)

1) Start at the last row, and find all the rows that have the same
value in Col A.

2) Iterate through each of those rows in Col B to determine if they
have only one type of value, or multiple types. (Do this by comparing
all values against the the value in Col B in the last row... if any are
different, you keep)

3) If any were different from step 2, delete all the rows that
correspond to that section.

4) Repeat 1-3, starting one row before the first row from the previous
section.

ie. For your example, last row is row 10. Rows 9-10 have the same
value in Col A. Go through values in Col B, find they are the same.
Delete rows 9-10. Repeat starting in row 8 (9 - 1).

Scott

ALATL wrote:
I have the following data in Columns A and B. I would like to write code for
all rows in columns A and B that:

delete the rows for Example1 since the values in Column B are the same
delete the row for Example 2 since it only has one value
keep the rows for Example 3 since the values in Column B are NOT unique
delete the rows for Example 4 since the value in Column B are the same

Column A ColumnB
Example1 Create PO
Example1 Create PO
Example1 Create PO
Example2 Create PO
Example3 Approve Invoices
Example3 Approve Invoices
Example3 Create PO
Example4 Approve Invoices
Example4 Approve Invoices


Thanks!


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
Delete Rows Where Value in Column V is Less than 2.5? SteveC Excel Programming 1 February 1st 06 09:18 PM
Delete rows with nothing in Column B marlea[_12_] Excel Programming 3 January 31st 06 03:39 PM
delete rows if value in column D is repeated DKY[_70_] Excel Programming 5 August 12th 05 11:07 PM
Delete all rows where Column A contains Text D Hafer - TFE Excel Worksheet Functions 3 July 1st 05 06:03 PM
Delete All Rows That Column A value is not in Column A of Sheet2 [email protected] Excel Programming 2 September 3rd 04 09:13 PM


All times are GMT +1. The time now is 11:35 PM.

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

About Us

"It's about Microsoft Excel"