Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
delete group of check box all at once | Excel Discussion (Misc queries) | |||
Macro to delete a group of CELLS | Excel Discussion (Misc queries) | |||
Delete a group of alternate cells | New Users to Excel | |||
Have VBA delete a group of cells, move information over, then add | Excel Discussion (Misc queries) | |||
delete group box | Excel Discussion (Misc queries) |