View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Formula or script needed

the code below expects two worksheets called "Sheet1" and "Sheet2". It
expects Sheet1 to be blank. It will create sheet1 based on the data in
sheet2.


Sub MakeSummary()

NewRow = 1
RowCount = 1
With Sheets("sheet2")
Do While .Range("A" & RowCount) < ""
CombineNumber = .Range("A" & RowCount).Text & _
" " & .Range("B" & RowCount).Text
JDRNumber = .Range("C" & RowCount)
With Sheets("Sheet1")
Set c = .Columns("A").Find(what:=CombineNumber, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
.Range("A" & NewRow) = CombineNumber
.Range("B" & NewRow) = JDRNumber
NewRow = NewRow + 1
Else
.Range("B" & c.Row) = .Range("B" & c.Row) & _
", " & JDRNumber
End If

End With
RowCount = RowCount + 1
Loop
End With
End Sub


"Jeremy" wrote:

I am trying to use a formula or script to take the data from Sheet two column
C to sheet one given certain criteria in sheet one column A and sheet two
columns A and B. Below are the two sheets along with what sheet one should
look like after. This is for a rather large range of data.

Thank you
Jeremy

Sheet one
A B
1 5657 0020
2 5657 0021
3 1345 0010
4 1345 0020
5 1342 0020


Sheet two
A B C
1 5657 0020 JDR1
2 5657 0020 JDR2
3 5657 0020 JDR3
4 5657 0021 JDR4
5 1345 0010 JDR5
6 1345 0020 JDR6
7 1342 0020 JDR7
8 1342 0020 JDR8
9 1342 0020 JDR9



What sheet one should look like on sheet one from data in sheet two columns C

A B
1 5657 0020 JDR1, JDR2, JDR3
2 5657 0021 JDR4
3 1345 0010 JDR5
4 1345 0020 JDR6
5 1342 0020 JDR7, JDR8, JDR9

Can look like and go to e and so on if more JDR numbers corresponding to A
in sheet one

A B C D E F
1 5657 0020 JDR1 JDR2 JDR3
2 5657 0021 JDR4
3 1345 0010 JDR5
4 1345 0020 JDR6
5 1342 0020 JDR7 JDR8 JDR9