You are here:

Excel/merge info on duplicate rows found in a specific column


"Bob. in the attached image i have conditional formatting to highlight duplicate case numbers. What i need to do is if there are duplicate case numbers, the procedure names on the duplicate rows need to be combined. Note-some duplicates may have 3 rows.
can you help? i tried doing this with my access query but no success so hoping you can help."

Assuming the first thing in your image is in cell A1:

Sub Combine()
   Dim stg As String, n As Integer
   n = Range("B50000").End(xlUp).Row
   m = n + 2
   For i = 1 To n + 1
       If i = 1 Then
         stg = Cells(i, 1).Value
         If Cells(i, 2).Value = Cells(i - 1, 2).Value Then
         stg = stg & "/" & Cells(i, 1).Value
         Cells(m, 1).Value = stg
         Cells(m, 2).Value = Cells(i - 1, 2).Value
         m = m + 1
         stg = Cells(i, 1).Value
         End If
       End If
   Columns.WrapText = True
End Sub
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Bob Umlas


I`m a Microsoft Excel MVP (Most Valuable Professional) and have been since the inception of the program in 1995. I can answer every kind of Excel question except: API, Importing/exporting to other programs (powerpoint, word,...) Also check out my in-person training link at


Worked with MS Excel since version 0.99 (on the Mac!). Was contributing editor to Excellence Magazine, having written >300 articles. John Walkenbach said of me "I finally met someone who knows as much about Excel as I do."

Excellence, The Expert, Microsoft

BA in math, Hofstra University, 1965

Awards and Honors
Led sessions for the Convergence 2004-2006 seminar on Excel tips & tricks

©2017 All rights reserved.