Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Group and Delete

This will do it:

Code
-------------------
Sub test()

Dim i As Long
Dim lastVal As String
Dim lastRow As Long

lastRow = Range("A65536").End(xlUp).Row
lastVal = ""

For i = Range("A65536").End(xlUp).Row To 1 Step -1
If Range("A" & i).Value & Range("B" & i).Value = lastVal Then
Range("A" & i).EntireRow.Delete
End If
lastVal = Range("A" & i).Value & Range("B" & i).Value
Next

End Su
-------------------

It assumes that the group you speak of is column a and b. It works b
starting at the bottom and working up. If the values in columns a an
b are the same as the last ones, it will delete them. Since it goe
bottom to top, it keeps the bottom most ones.

After reading your message, you cang change the places where I us
Range("A" & i).Value & Range("B" & i).Value to just Range("A"
i).Value since you only specified Customer ID.

New code would be
Code
-------------------
Sub test()

Dim i As Long
Dim lastVal As String
Dim lastRow As Long

lastRow = Range("A65536").End(xlUp).Row
lastVal = ""

For i = Range("A65536").End(xlUp).Row To 1 Step -1
If Range("A" & i).Value = lastVal Then
Range("A" & i).EntireRow.Delete
End If
lastVal = Range("A" & i).Value
Next

End Su
-------------------





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

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 group of check box all at once Marta Excel Discussion (Misc queries) 2 August 24th 06 10:40 AM
Macro to delete a group of CELLS Excel Discussion (Misc queries) 4 May 8th 06 04:29 PM
Delete a group of alternate cells poleary53 New Users to Excel 1 March 7th 06 11:05 PM
Have VBA delete a group of cells, move information over, then add Tina Bradshaw Excel Discussion (Misc queries) 0 February 22nd 06 04:07 PM
delete group box Mass group box delete Excel Discussion (Misc queries) 4 October 16th 05 02:43 AM


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