kindly provide excel file
BEFORE
HH Acct
1 1234
1 2345
1 3456
1 4567
2 9876
2 8765
3 1113
4 5556
4 4447
4 3335
AFTER
HH Acct1 Acct2 Acct3 Acct4 Acct5 Acct6 Acct7
1 1234 2345 3456 4567
2 9876 8765 8765
3 1113
4 5556 4447 3335
kindly provide excel file
BEFORE
HH Acct
1 1234
1 2345
1 3456
1 4567
2 9876
2 8765
3 1113
4 5556
4 4447
4 3335
AFTER
HH Acct1 Acct2 Acct3 Acct4 Acct5 Acct6 Acct7
1 1234 2345 3456 4567
2 9876 8765 8765
3 1113
4 5556 4447 3335
See the attached file, after running macro consolidate.
![]()
Sub Consolidate() 'JBeaucaire (9/18/2009) 'Columnar data is Sorted/Matched by column A values, merge all other cells into row format Dim LastRow As Long, NextCol As Long Dim LastCol As Long, Rw As Long, Cnt As Long Dim delRNG As Range Application.ScreenUpdating = False 'Sort data LastRow = Range("A" & Rows.Count).End(xlUp).Row Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlYes 'Seed the delete range Set delRNG = Range("A" & LastRow + 10) 'Group matching names For Rw = LastRow To 2 Step -1 If Cells(Rw, "A").Value = Cells(Rw - 1, "A").Value Then Range(Cells(Rw, "B"), Cells(Rw, Columns.Count).End(xlToLeft)).Copy _ Cells(Rw - 1, Columns.Count).End(xlToLeft).Offset(0, 1) Set delRNG = Union(delRNG, Range("A" & Rw)) End If Next Rw 'Delete unneeded rows all at once delRNG.EntireRow.Delete (xlShiftUp) Set delRNG = Nothing 'Add titles NextCol = Cells(1, Columns.Count).End(xlToLeft).Column + 1 LastCol = Cells(1, 1).CurrentRegion.Columns.Count Range("B1", Cells(1, NextCol - 1)).Copy Range(Cells(1, NextCol), Cells(1, LastCol)) Cells.Columns.AutoFit Application.ScreenUpdating = True End Sub
Notice my main language is not English.
I appreciate it, if you reply on my solution.
If you are satisfied with the solution, please mark the question solved.
You can add reputation by clicking on the star * add reputation.
Oeldere,
This macro looks great. I am actually trying to do the exact opposite (taking a multi-column view and creating a separate row for each combination) I'm having trouble switching your code for this purpose.
Would you be able to show me how to reverse this macro?
Thanks
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks