Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Combine multiple rows into one.

I am trying to combine multiple rows into one. The data is in five columns.
The main identifiers are the first few characters of column A (F75 through
F77 with varying number of occurances). I would like to extract each grouping
(first F75 row through F77 row and so on) and place into one row. A space in
between data would be fine as I imagine I could do a text to column delimit
later. Here is an example of what it looks like. I am truncating the data for
ease of viewing.

Thank you in advance.

F75 00141 09022 0
F75
F75 0712 0
F76 08 010 0
F76 09022009 0
F77 0
F75 00141 090 0
F75 24 2
F75 090 01
F76 08 01 0
F76 090 0
F76 08 01 0
F76 09 0
F77 0

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Combine multiple rows into one.

Try this macro

Sub CombineRows()

Set OldSht = Sheets("sheet1")
Set NewSht = Sheets("sheet2")

With OldSht
NewRowCount = 0
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
OldID = ""
For OldRowCount = 1 To LastRow
NewId = .Range("A" & OldRowCount)
LastCol = .Cells(OldRowCount, Columns.Count).End(xlToLeft).Column
If LastCol 1 Then
If NewId < OldID Then
NewRowCount = NewRowCount + 1
NewSht.Range("A" & NewRowCount) = NewId
OldID = NewId
NewColCount = 2
End If

For ColCount = 2 To LastCol
NewSht.Cells(NewRowCount, NewColCount) = .Cells(OldRowCount,
ColCount)
NewColCount = NewColCount + 1
Next ColCount
End If
Next OldRowCount

End With

End Sub


"Linnaeus" wrote:

I am trying to combine multiple rows into one. The data is in five columns.
The main identifiers are the first few characters of column A (F75 through
F77 with varying number of occurances). I would like to extract each grouping
(first F75 row through F77 row and so on) and place into one row. A space in
between data would be fine as I imagine I could do a text to column delimit
later. Here is an example of what it looks like. I am truncating the data for
ease of viewing.

Thank you in advance.

F75 00141 09022 0
F75
F75 0712 0
F76 08 010 0
F76 09022009 0
F77 0
F75 00141 090 0
F75 24 2
F75 090 01
F76 08 01 0
F76 090 0
F76 08 01 0
F76 09 0
F77 0

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Combine multiple rows into one.

Thank you very much. I will make the modifications and see if that does the
trick.

"Joel" wrote:

Try this macro

Sub CombineRows()

Set OldSht = Sheets("sheet1")
Set NewSht = Sheets("sheet2")

With OldSht
NewRowCount = 0
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
OldID = ""
For OldRowCount = 1 To LastRow
NewId = .Range("A" & OldRowCount)
LastCol = .Cells(OldRowCount, Columns.Count).End(xlToLeft).Column
If LastCol 1 Then
If NewId < OldID Then
NewRowCount = NewRowCount + 1
NewSht.Range("A" & NewRowCount) = NewId
OldID = NewId
NewColCount = 2
End If

For ColCount = 2 To LastCol
NewSht.Cells(NewRowCount, NewColCount) = .Cells(OldRowCount,
ColCount)
NewColCount = NewColCount + 1
Next ColCount
End If
Next OldRowCount

End With

End Sub


"Linnaeus" wrote:

I am trying to combine multiple rows into one. The data is in five columns.
The main identifiers are the first few characters of column A (F75 through
F77 with varying number of occurances). I would like to extract each grouping
(first F75 row through F77 row and so on) and place into one row. A space in
between data would be fine as I imagine I could do a text to column delimit
later. Here is an example of what it looks like. I am truncating the data for
ease of viewing.

Thank you in advance.

F75 00141 09022 0
F75
F75 0712 0
F76 08 010 0
F76 09022009 0
F77 0
F75 00141 090 0
F75 24 2
F75 090 01
F76 08 01 0
F76 090 0
F76 08 01 0
F76 09 0
F77 0

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
combine multiple rows in one column Shamoun Ilyas Excel Worksheet Functions 3 March 30th 09 10:18 AM
How to combine information from multiple rows into one Zuzie Excel Discussion (Misc queries) 0 July 24th 08 12:48 PM
combine contents of multiple rows in one row Rohit Excel Discussion (Misc queries) 1 July 14th 08 10:22 PM
How do I combine multiple rows with like data in Excel? CAW@NG&G Excel Discussion (Misc queries) 2 May 22nd 07 06:47 PM
Combine Data from Multiple Rows MR Excel Discussion (Misc queries) 1 January 24th 07 06:44 PM


All times are GMT +1. The time now is 01:23 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"