View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Tough - show a hierarchy

It may not cause a problem, but I should have added the following line
between the end if and Next i statements.

End If
Set colTemp = New Collection '<< Add this line
Next i

"comparini3000" wrote:



"comparini3000" wrote:

My company identifies products like this: #####-###-AAA, with specific
numbers taking the place of the # sign and specific letters taking the place
of the A. the 5-digit number identifies the type of product, the 3-digit
number identifies the specific model for the type of product, and the 3
letters identify where the part was made.

I have already split the product numbers into the three components, but I
want to remove any repetitions in cell values. To show a sort of a hierarchy.
I want to go from this:

__A__ _B__ _C_
12345|123|ABC
12345|123|SDE
12345|321|RSW
54321|098|CBA
54321|890|ABC


to this:
__A__ _B__ _C_
12345|123|ABC
| |SDE
|321|RSW
54321|098|CBA
|890|ABC

how would i do that? thanks!

comparini3000


sorry, my last diagram got messed up, but all the values should line up. i
figured out a working code, it's not the most efficient, but it works:

__________________________________________________ ___________
Option Explicit
-----------------------------------------------------------------------
Sub delete_nonunique()
Dim x As Integer, I As Variant
Range("I1").End(xlDown).Select
x = Selection.Row
For Each I In Range("I2:I" & x):
If Selection.Value = ActiveCell.Offset(-1, 0).Range("A1").Value Then
Selection.ClearContents
ActiveCell.Offset(-2, 0).Range("A1").Select
x = x - 2
On Error GoTo ErrMsg
Else
x = x - 2
Range("I" & x).Select
On Error GoTo ErrMsg
End If
Next I
ErrMsg:
Range("I2").Select
End Sub
__________________________________________________ ____________

the reason i have it offset the selection by 2 is because i know the "Next
I" will select the cell below the current selection. Is there some sort of
opposite to "Next I"?

thanks

comparini3000