Mass concatenation, varying number of rows per instance

bikeking8

New Member
Joined
Aug 13, 2013
Messages
2
I have a spreadsheet with 35,000+ rows I need to analyze. Specifically, I need to find which departments have similar values as well as how similar they are. What I've come up with is the generation of a concatenated field so I can quickly use excel to analyze it all. I can't seem to figure this out, though, since the number of departments on each floor differs as demonstrated in the example. Is there any way to do this without going through all 35,000 rows and using the "=A1:A6" [F9 Button] technique?

[TABLE="width: 500"]
<TBODY>[TR]
[TD="align: center"]DEPARTMENT[/TD]
[TD="align: center"]VALUE CATEGORY[/TD]
[TD="align: center"]VALUE[/TD]
[TD="align: center"]DESIRED OUTCOME[/TD]
[/TR]
[TR]
[TD="align: center"]Dept 1 Flr A[/TD]
[TD="align: center"]Value 1[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]YNNY[/TD]
[/TR]
[TR]
[TD="align: center"]Dept 1 Flr A[/TD]
[TD="align: center"]Value 2[/TD]
[TD="align: center"]N[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]Dept 1 Flr A[/TD]
[TD="align: center"]Value 3[/TD]
[TD="align: center"]N[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]Dept 1 Flr A[/TD]
[TD="align: center"]Value 4[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]Dept 2 Flr A[/TD]
[TD="align: center"]Value 1[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]YYNN[/TD]
[/TR]
[TR]
[TD="align: center"]Dept 2 Flr A[/TD]
[TD="align: center"]Value 2[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]Dept 2 Flr A[/TD]
[TD="align: center"]Value 3[/TD]
[TD="align: center"]N[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]Dept 2 Flr A[/TD]
[TD="align: center"]Value 4[/TD]
[TD="align: center"]N[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]Dept 3 Flr B[/TD]
[TD="align: center"]Value 5[/TD]
[TD="align: center"]G[/TD]
[TD="align: center"]GHH[/TD]
[/TR]
[TR]
[TD="align: center"]Dept 3 Flr B[/TD]
[TD="align: center"]Value 6[/TD]
[TD="align: center"]H[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]Dept 3 Flr B[/TD]
[TD="align: center"]Value 7[/TD]
[TD="align: center"]H[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]Dept 4 Flr B[/TD]
[TD="align: center"]Value 5[/TD]
[TD="align: center"]G[/TD]
[TD="align: center"]GHG[/TD]
[/TR]
[TR]
[TD="align: center"]Dept 4 Flr B[/TD]
[TD="align: center"]Value 6[/TD]
[TD="align: center"]H[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]Dept 4 Flr B[/TD]
[TD="align: center"]Value 7[/TD]
[TD="align: center"]G[/TD]
[TD][/TD]
[/TR]
</TBODY>[/TABLE]
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I figured out a way to do it via SQL query. I'd still be open to suggestions on how to do this in excel, though.
 
Upvote 0

Excel 2010
ABC
1DEPARTMENTVALUE CATEGORYVALUE
2Dept 1 Flr AValue 1Y
3Dept 1 Flr AValue 2N
4Dept 1 Flr AValue 3N
5Dept 1 Flr AValue 4Y
6Dept 2 Flr AValue 1Y
7Dept 2 Flr AValue 2Y
8Dept 2 Flr AValue 3N
9Dept 2 Flr AValue 4N
10Dept 3 Flr BValue 5G
11Dept 3 Flr BValue 6H
12Dept 3 Flr BValue 7H
13Dept 4 Flr BValue 5G
14Dept 4 Flr BValue 6H
15Dept 4 Flr BValue 7G
Sheet5 (2)


Code:
Sub concatgroups()
Dim x As Integer
Dim y As Integer
Dim lr As Integer
Dim groupstr As String
lr = Cells(Rows.Count, 1).End(xlUp).Row
groupstr = ""
y = 0
For x = 2 To lr
y = y + 1
groupstr = groupstr & Cells(x, 3).Value
If Cells(x, 1).Value <> Cells(x + 1, 1).Value Then
Cells(x - y + 1, 4).Value = groupstr
groupstr = ""
y = 0
Else
End If
Next
End Sub



Excel 2010
ABCD
1DEPARTMENTVALUE CATEGORYVALUE
2Dept 1 Flr AValue 1YYNNY
3Dept 1 Flr AValue 2N
4Dept 1 Flr AValue 3N
5Dept 1 Flr AValue 4Y
6Dept 2 Flr AValue 1YYYNN
7Dept 2 Flr AValue 2Y
8Dept 2 Flr AValue 3N
9Dept 2 Flr AValue 4N
10Dept 3 Flr BValue 5GGHH
11Dept 3 Flr BValue 6H
12Dept 3 Flr BValue 7H
13Dept 4 Flr BValue 5GGHG
14Dept 4 Flr BValue 6H
15Dept 4 Flr BValue 7G
Sheet5 (2)
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top