
' Do not step RowCrnt because there may be another match for it RowsMatch = True ' Assume match until find otherwise Please correct and try again.", _Īpplication.StatusBar = "Row " & RowCrnt & " of " & RowLast Every column must be specified onceĬheckOK = False ' Set true if check successfulĬall MsgBox("I was unable to find column " & ColCrnt & " in either" & _ ' Find last used column and last used rowĬolLast =. ' Replace "Merge" with the name of your worksheet ' Column numbers must be in ascending order. ' are to be appended to the first row of a matching pair. ' Defines the columns for which values from the second row ' adjacent rows for the second row to be merged into the ' Defines the columns which must have the same values in two ' Record seconds since midnight at start of routine.
#Merge duplicate rows in excel 2013 code#
' Stops the code from being interrupted by event routines ' Defines the string to be placed between the value in the first row ' from row 600 or whatever (might be important). ' looking at header rows (not very important) and allows a restart ' Defines the first row to be considered for merging. ' the first row and then deleting the second row. ' by appending the contents of the other columns from the second row to ' Merges adjacent rows for which all columns listed in ColMatch are equal Merges Rows based on specifics - separator for non-duplicates is vblf - this is quite close but doesn't keep formatting/lines (credit: Tony Dallimore) Some code that may assist that I've tried piecing together: If they are all merged into the same cell and separated with comma or alike, it becomes very hard to make sense. Hopefully the above makes sense - everything I've come across/found/tried has resulted in the duplicates being merged fine but the unique values all being merged with commas, spaces and so on - I need the unique values to keep their line format so they can be read correctly.

Now that I've successfully confused you all haha - here's a visual aid :). Currently I have 50 columns, of which the a number of rows are duplicates with only the end columns changing - what I would like to do is merge the duplicate rows, but keep the unique cells (and where I am falling flat - is they keep their format and location). xlsm and adding a module in) to produce the desired result. csv will then run through a macro (just been converting the. csv (varying length of rows) however the columns (and their order) remain constant - this. I currently take output in the form of a. I have been currently working on a problem for the last few days, using a number of resources throughout this fantastic site and others - mixing and merging code to try and achieve (what I think is a unique problem) but have not quite landed successfully on a solution.
