Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Combine Two Arrays Into One. Tough. | Excel Worksheet Functions | |||
combine rows and sum data with the same id | Excel Discussion (Misc queries) | |||
Combine Data from Multiple Rows | Excel Discussion (Misc queries) | |||
Combine data rows in Pie Chart | Charts and Charting in Excel | |||
Combine rows of data in a worksheet | Excel Programming |