Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Cam Cam is offline
external usenet poster
 
Posts: 165
Default macro to delete hidden or unused rows

Hello,

Here is what I am trying to achieve. For order with multiple oper, it only
returns one order with the lowest oper number. I need help with a macro to
filter out so only the first operation of each Order number and then delete
all the rows that are not needed. Thanks

Table with the following data:
Part Order Oper WC Date
AAA 123 1000 8951 1/2/08
AAA 123 2000 8951 1/3/08
AAA 123 3000 8951 1/7/08
AAA 123 4000 8951 1/3/08
ABC 205 5000 8951 1/4/08
ABC 205 6000 8951 1/8/08
ABZ 314 1000 8951 1/3/08
AAH 380 2000 8951 1/3/08

result of query data I like to achieve:
Part Order Oper WC Date
AAA 123 1000 8951 1/2/08
ABC 205 5000 8951 1/4/08
ABZ 314 1000 8951 1/3/08
AAH 380 2000 8951 1/3/08

Rows to be deleted or moved to some else whe
AAA 123 2000 8951 1/3/08
AAA 123 3000 8951 1/7/08
AAA 123 4000 8951 1/3/08
ABC 205 6000 8951 1/8/08



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default macro to delete hidden or unused rows

Sub cam()
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = n To 2 Step -1
If Cells(i, 1).Value = Cells(i - 1, 1).Value Then
If Cells(i, 2).Value = Cells(i - 1, 2).Value Then
Cells(i, 1).EntireRow.Delete
End If
End If
Next
End Sub

--
Gary''s Student - gsnu200771


"Cam" wrote:

Hello,

Here is what I am trying to achieve. For order with multiple oper, it only
returns one order with the lowest oper number. I need help with a macro to
filter out so only the first operation of each Order number and then delete
all the rows that are not needed. Thanks

Table with the following data:
Part Order Oper WC Date
AAA 123 1000 8951 1/2/08
AAA 123 2000 8951 1/3/08
AAA 123 3000 8951 1/7/08
AAA 123 4000 8951 1/3/08
ABC 205 5000 8951 1/4/08
ABC 205 6000 8951 1/8/08
ABZ 314 1000 8951 1/3/08
AAH 380 2000 8951 1/3/08

result of query data I like to achieve:
Part Order Oper WC Date
AAA 123 1000 8951 1/2/08
ABC 205 5000 8951 1/4/08
ABZ 314 1000 8951 1/3/08
AAH 380 2000 8951 1/3/08

Rows to be deleted or moved to some else whe
AAA 123 2000 8951 1/3/08
AAA 123 3000 8951 1/7/08
AAA 123 4000 8951 1/3/08
ABC 205 6000 8951 1/8/08



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
how do I delete hidden rows or columns without doing it manually? Eastman22 Excel Worksheet Functions 1 June 18th 07 04:52 PM
How do I delete hidden records/rows? Melissa M Excel Discussion (Misc queries) 2 June 8th 07 06:27 PM
Find Hidden rows and delete ttbbgg Excel Programming 7 October 27th 06 06:16 PM
Delete Unused (4000) Rows VexedFist[_2_] Excel Programming 3 September 22nd 06 09:54 PM
VB Code to Delete Unused Rows Ken[_18_] Excel Programming 2 October 1st 04 04:35 AM


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

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"