Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Donovan Panone
 
Posts: n/a
Default How do I combine rows, combining duplicates as well as concatenati

I'm trying to combine rows of data and I need a certain column to concatenate
only if it is in a group of rows that have duplicate information in another
column.

Example:

Before...

Column 1 Column 2
X A
X B
Y C
Y D

Desired After...

Column 1 Column 2
X AB
Y CD

This is for a spreadsheet with thousands of rows

Any suggestions?

  #2   Report Post  
Otto Moehrbach
 
Posts: n/a
Default

Donovan
Your example shows 2 cells in Column 1 which are the same, and then you
concatenate the corresponding 2 cells in Column 2. Can your data have more
than 2 cells in Column 1 with the same value? If so, do you want to
concatenate all the corresponding cells in Column 2?
HTH Otto
"Donovan Panone" <Donovan wrote in message
...
I'm trying to combine rows of data and I need a certain column to
concatenate
only if it is in a group of rows that have duplicate information in
another
column.

Example:

Before...

Column 1 Column 2
X A
X B
Y C
Y D

Desired After...

Column 1 Column 2
X AB
Y CD

This is for a spreadsheet with thousands of rows

Any suggestions?



  #3   Report Post  
Donovan Panone
 
Posts: n/a
Default

Thanks for the reply Otto. It looks like someone else at our office figured
everything out, so don't worry about it.

"Otto Moehrbach" wrote:

Donovan
Your example shows 2 cells in Column 1 which are the same, and then you
concatenate the corresponding 2 cells in Column 2. Can your data have more
than 2 cells in Column 1 with the same value? If so, do you want to
concatenate all the corresponding cells in Column 2?
HTH Otto
"Donovan Panone" <Donovan wrote in message
...
I'm trying to combine rows of data and I need a certain column to
concatenate
only if it is in a group of rows that have duplicate information in
another
column.

Example:

Before...

Column 1 Column 2
X A
X B
Y C
Y D

Desired After...

Column 1 Column 2
X AB
Y CD

This is for a spreadsheet with thousands of rows

Any suggestions?




  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

Maybe a macro????

Option Explicit
Sub testme01()

Dim curWks As Worksheet
Dim newWks As Worksheet
Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long
Dim oRow As Long
Dim PrevKey As String
Dim TempStr As String

Set curWks = Worksheets("sheet1")
Set newWks = Worksheets.Add

With curWks
FirstRow = 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

oRow = 1
TempStr = ""

'do the first
PrevKey = .Cells(FirstRow, "A").Value
TempStr = .Cells(FirstRow, "B").Value

'do the rest
For iRow = FirstRow + 1 To LastRow + 1
'lastrow + 1 makes sure last entry is processed
If .Cells(iRow, "A").Value = PrevKey Then
TempStr = TempStr & .Cells(iRow, "B").Value
Else
newWks.Cells(oRow, "A").Value = PrevKey
newWks.Cells(oRow, "B").Value = TempStr
PrevKey = .Cells(iRow, "A").Value
TempStr = .Cells(iRow, "B").Value
oRow = oRow + 1
End If
Next iRow
End With

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Donovan Panone wrote:

I'm trying to combine rows of data and I need a certain column to concatenate
only if it is in a group of rows that have duplicate information in another
column.

Example:

Before...

Column 1 Column 2
X A
X B
Y C
Y D

Desired After...

Column 1 Column 2
X AB
Y CD

This is for a spreadsheet with thousands of rows

Any suggestions?


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert rows based on specific value bob Excel Worksheet Functions 6 February 29th 08 07:11 PM
Find duplicate rows then deleting them SSHO_99 Excel Worksheet Functions 4 May 4th 07 11:17 AM
Row selections by row # OR by even/odd rows in another spreadsheet Tom Excel Discussion (Misc queries) 0 February 9th 05 04:03 PM
Adding Rows to Master Sheet Excel Newbie New Users to Excel 1 December 23rd 04 10:56 PM
Copying Rows when hiding other rows Neutron1871 Excel Worksheet Functions 2 November 3rd 04 11:38 PM


All times are GMT +1. The time now is 07:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"