View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default need assistance with some find or lookup related code...

If your data is already sorted by column A:

Option Explicit
Sub testme()

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

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, "A").Value = .Cells(iRow - 1, "A").Value Then
.Cells(iRow - 1, "B").Value _
= .Cells(iRow - 1, "B").Value & " " & .Cells(iRow, "B").Value
.Rows(iRow).Delete
End If
Next iRow
End With

End Sub

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

hshayh0rn wrote:

I have a spread sheet that is set-up similar to this:

377004 AA1
377004 BI2
377004 HH6
377008 DFE
377009 AA1
377009 DFE
377025 BI2
377025 CCI

I need a function or some VB code that would create a new cell with the code
in column A only listed once and then the codes in column B concatenated
together (with spaces between each code). It should look something like this:

377004 AA1 BI2 HH6
377008 DFE
377009 AA1 DFE
377025 BI2 CCI

Anyone have some ideas?


--

Dave Peterson