View Single Post
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Try this against a copy of your worksheet--it will destroy the existing data.

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long

Set wks = Worksheets("sheet1")

With wks
FirstRow = 2 'headers in row 1???
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row

For iRow = LastRow To FirstRow + 1 Step -1
If .Cells(iRow, "B").Value = .Cells(iRow - 1, "B").Value Then
.Cells(iRow - 1, "E").Value _
= .Cells(iRow - 1, "E").Value _
& vbLf & .Cells(iRow, "E").Value
.Rows(iRow).Delete
End If
Next iRow
End With

End Sub

The vblf is the same as the alt-enter (to force a new line within the cell).

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Jacky D. wrote:

I have a spreadsheet that I have sorted and contains duplicate cells of
information within the same columns, but has needed information within the
row. I need some help writing a formula that would allow me to do as
discribed below down the entire worksheet:
If Cell B2= B3, Then add value in cell E3 to cell E2, retaining the E2
cell vaue, using sometype of delimiter such as a comma or hard return to
seperate the 2 values, then delete row 3 and move down through the entire
worksheet.
Any help or advice would be appreciated.
Thanks,
Jacky Del Hoyo


--

Dave Peterson