I need VBA Help for Excel spreadsheet -- Please!
Jim:
Pretty nifty approach. It worked well except that the notes in column b for
the very first row didn't get copied. Cool concatenation code!! I will add
this to my library of examples.
--
Rich Locus
Logicwurks, LLC
"Jim Berglund" wrote:
This works - make sure your data is in 3 columns, starting in Cell A1
Jim Berglund
Sub Concatenate()
Dim i, j, n, p As Integer
i = 2
n = 2
p = 2
Cells(i, 4).Value = Cells(i, 1).Value
ActiveSheet.Range("A1").Select
j = ActiveCell.CurrentRegion.Rows.Count
For i = 2 To j
While Cells(i, 1).Value = Cells(p, 4).Value
Cells(n, 5).Value = (Cells(n, 5).Value & ", " & Cells(i, 2).Value) & "
$" & Cells(i, 3).Value
Cells(n, 6).Value = Cells(n, 6).Value + Cells(i, 3).Value
i = i + 1
Wend
p = p + 1
n = n + 1
Cells(p, 4).Value = Cells(i, 1).Value
i = i - 1
Next
End Sub
"ILoveMyCorgi" wrote in message
...
I have an Excel spreadsheet with three columns: ColA has a student number,
ColB has a comment, and ColC has an amount. I have many rows of different
comments and amounts for the same student number followed by rows with new
student numbers and so on. I need to move all of columns B and columns C
to
the same row of the first line for the student number and move on to the
next
student number. What I am trying to do is have all the data for one
student
on one row so that I can merge the data with a Word document.
For instance,
1495 writing in book $10.00
1495 football trans $ 5.00
3456 Water damage $15.00
3456 Lost Textbook $35.00
Witn an outcome of:
1495 writing in book $10.00 football trans $5.00
3456 Water damage $15.00 Lost Textbook $35.00
I hope someone can help me with this. Thak you.
.
|