|
-
Feb 17th, 2009, 08:25 PM
#1
Thread Starter
Addicted Member
Excel Data Grouping a better way to roll
need your help to roll a better way...
i created macro to group a data with same value..
and group them in another column
col a - data to be group
col b - reference value
col c - grouped data with same value
like:
Col A Col B
R1 10k
R2 5k
R3 3k
R4 10k
R5 3k
R6 5k
R7 3k
R8 10k
R9 5k
R10 10k
Col C ' where data with same value will be group like:
R1, R4, R8, R10 ' All got 1Ok value
R2 , R6, R9 ' All 5k value
R3, R5, R7 ' All got 3k value
i search col b for same value and erase the value in order not to
duplicate the grouping..
is there a way to group data without erasing the reference value?
any input is greatly appreciated..
below is my code so far..it's working.. the only thing it deletes the reference value at col b
thanks..
Code:
Sub x()
Dim x, y, z As String
Dim i, icount As Integer
Dim lastrow As Integer
icount = 1
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lastrow + 1
x = Range("b" & i).Value
'Range("c" & i).Value = x
If x = "" Then
GoTo out
End If
While icount <> lastrow + 1
y = Range("b" & icount).Value
If y = x Then
z = Range("a" & icount).Value
Range("c" & i).Value = Range("c" & i).Value + " " + z
Range("b" & icount).Value = ""
End If
icount = icount + 1
Wend
out:
icount = 1
Next
Last edited by JJJCR_FOX; Feb 17th, 2009 at 08:29 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|