Hi All,
Cant quite get my little macro to work.
Basic premise is i have a table of customer records in the following format.
Customer1 | Invoice no. | Invoice class | Due Date | Amount
Customer1 | Invoice no. | Invoice class | Due Date | Amount
Customer1 | Invoice no. | Invoice class | Due Date | Amount
Customer2 | Invoice no. | Invoice class | Due Date | Amount
Customer2 | Invoice no. | Invoice class | Due Date | Amount
Customer3 | Invoice no. | Invoice class | Due Date | Amount
What i need to do is to sort these records so that i have 1 row for each customer which repeats the various fields accross the row instead of listing them on multiple rows.
e.g
Customer1 | Invoice no. | Invoice class | Due Date | Amount | Invoice no. | Invoice class | Due Date | Amount
Problem that i am having is remembering where the customer "changes"
see my attempt:
Dim LSearchRow As Integer
Dim Ccount As Integer
LSearchRow = 2
Ccount = 0
While Len(Range("A" & CStr(LSearchRow)).Value) > 0
MARKER:
Cells(CStr(LSearchRow), 2).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Cut
If Range("A" & CStr(LSearchRow)).Value = Range("A" & CStr(LSearchRow - 1)).Value Then
Ccount = Ccount + 1
Cells(CStr(LSearchRow - Ccount), 2).Select
Selection.End(xlToRight).Select
Selection.End(xlToRight).Offset(0, 1).Select
ActiveSheet.Paste
LSearchRow = LSearchRow + 1
GoTo MARKER
End If
Cells(CStr(LSearchRow), 2).Select
Selection.End(xlToRight).Offset(0, 1).Select
ActiveSheet.Paste
LSearchRow = LSearchRow + 1
Wend
End Sub
Any help would be greatly appreciated! - Still struggling with this one.
Bookmarks