PDA

View Full Version : Solved: Group Data to another Cell



joms
02-23-2009, 12:59 AM
help on how to group data with same value to another cell.
col a - data to be group
col b - reference value
col c - grouped data with same value

like:
Col A Col B
C1 10uF
C2 100uF
C3 10nF
C4 100pF
C5 10uF
c6 100uF
C7 10nF
C8 100pF
C9 100uF
C10 10nF
C11 10uF
C12 100uF

so i want to group in col c the data with same value
so it would look like this:

C1, C5, C11 --> All is 1OuF
C3, C7, C10 --> All is 10nF

any idea how to achieve this in macro.. thanks..

mdmackillop
02-23-2009, 01:44 AM
Welcome to VBAX.
I just answered a similar question here (http://www.thecodecage.com/forumz/excel-vba-programming/67468-merging-multiple-cells-into-single-cell.html). Can you manipulate the code to suit?

Bob Phillips
02-23-2009, 01:50 AM
Public Sub ProcessData()
Const TEST_COLUMN As String = "B" '<=== change to suit
Dim i As Long
Dim LastRow As Long
Dim cell As Range
Dim sh As Worksheet

With ActiveSheet

LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
.Range("A1").Resize(LastRow, 2).Sort Key1:=.Range("B1"), Order1:=xlAscending, Header:=xlNo
For i = LastRow - 1 To 1 Step -1

If .Cells(i, TEST_COLUMN).Value = .Cells(i + 1, TEST_COLUMN).Value Then

.Cells(i, "A").Value = .Cells(i, "A").Value & "," & .Cells(i + 1, "A").Value
.Rows(i + 1).Delete
End If
Next i
End With

End Sub

joms
02-23-2009, 05:34 AM
thanks xld, it works perfect.. :)

mdmackillop
02-23-2009, 12:12 PM
Hi Joms,
When you have a solution, please mark your thread Solved using the Thread Tools drop-down.

joms
02-25-2009, 02:50 AM
Hi Joms,
When you have a solution, please mark your thread Solved using the Thread Tools drop-down.

hi mdmackillop, thanks..i don't know that..newbie..:clap: