LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default combine rows of data to one row...tough one

Assumed is that Hire/Term/Benefit/Birth/Last Name/First Name are in columns A
through F respectively. Results will be pasted to columns H through M. Set
the startrow constant to the desired start row. Here it is assumed to be row
2. Hope it's what you wanted. Minimal testing.


Const startrow As Integer = 2

Sub CombineData()
Dim r As Range, r2 As Range
Dim c As Range, c2 As Range
Dim i As Long, x As Long
Dim row1 As Long, row2 As Long, row3 As Long
Dim nm As String, currnm As String, txt As String

i = startrow: row1 = startrow: row2 = 0
Set r = Range(Cells(i, 6), Cells(Rows.Count, 6).End(xlUp)(2))
row3 = r(r.Rows.Count).Row
For Each c In r.Cells
txt = Trim(c.Value)
If Len(txt) 0 Or c.Row = row3 Then
nm = Trim(c(1, 0).Value) & " " & txt
If currnm < nm Then
If Len(currnm) 0 Then
row2 = c.Row - 1
Set r2 = Range(Cells(row1, 1), Cells(row2, 4))
Set r2 = r2.SpecialCells(xlCellTypeConstants)
For Each c2 In r2.Cells
Cells(i, c2.Column + 7).Value = c2.Value
Next
Cells(i, 12).Value = c(0, 0).Value
Cells(i, 13).Value = c(0, 1).Value
i = i + 1
row1 = c.Row
End If
currnm = nm
End If
End If
Next
Set r = Nothing: Set r2 = Nothing
Set c = Nothing: Set c2 = Nothing
End Sub

Regards,
Greg


 
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 Two Arrays Into One. Tough. ryguy7272 Excel Worksheet Functions 4 May 8th 23 11:45 AM
combine rows and sum data with the same id tenny Excel Discussion (Misc queries) 4 April 4th 23 02:14 PM
Combine Data from Multiple Rows MR Excel Discussion (Misc queries) 1 January 24th 07 06:44 PM
Combine data rows in Pie Chart Jayntree Charts and Charting in Excel 1 March 16th 06 09:15 AM
Combine rows of data in a worksheet No Name Excel Programming 8 May 26th 04 09:29 PM


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