Hello!
I wonder if someone could help me? I'm trying to combine multiple rows into a single row. My data currently is formatted:
E-mail,First Name,Last Name,Event,Ticket Name,Spaces
email1,John,Taylor,C,81,5
email2,Mary,Smith,A,81,2
email2,Mary,Smith,D,144,1
email2,Mary,Smith,I,81,1
email2,Mary,Smith,G,82,1
email1,John,Taylor,A,81,2
I'd like to be able to combine rows so that my data looks like this:
E-mail,First Name,Last Name,Event,Ticket Name,Spaces,Event,Ticket Name,Spaces,Event,Ticket Name,Spaces,Event,Ticket Name,Spaces
email1,John,Taylor,C,81,5,A,81,2
email2,Mary,Smith,A,81,2,D,144,1,I,81,1,G,82,1
I found a macro on an old techguy thread which just about does the job, only it keeps repeating the last name and doesn't reprint the header. I've tried to edit it but I know nothing of Visual Basic and can't figure out how it's working. Here's the code from that thread:
Is anyone able to help?
Many thanks!
I wonder if someone could help me? I'm trying to combine multiple rows into a single row. My data currently is formatted:
E-mail,First Name,Last Name,Event,Ticket Name,Spaces
email1,John,Taylor,C,81,5
email2,Mary,Smith,A,81,2
email2,Mary,Smith,D,144,1
email2,Mary,Smith,I,81,1
email2,Mary,Smith,G,82,1
email1,John,Taylor,A,81,2
I'd like to be able to combine rows so that my data looks like this:
E-mail,First Name,Last Name,Event,Ticket Name,Spaces,Event,Ticket Name,Spaces,Event,Ticket Name,Spaces,Event,Ticket Name,Spaces
email1,John,Taylor,C,81,5,A,81,2
email2,Mary,Smith,A,81,2,D,144,1,I,81,1,G,82,1
I found a macro on an old techguy thread which just about does the job, only it keeps repeating the last name and doesn't reprint the header. I've tried to edit it but I know nothing of Visual Basic and can't figure out how it's working. Here's the code from that thread:
Code:
Sub test()
MainSheetRows = Range("B" & Rows.Count).End(xlUp).Row
For Each Cell In Range("B1:B" & MainSheetRows)
x = WorksheetFunction.CountIf(Range("New!B:B"), Cell)
If x = 0 Then
y = WorksheetFunction.CountA(Rows(Cell.Row))
Cell.Offset(, -1).Resize(, y).Copy Sheets("New").Range("A" & Rows.Count).End(xlUp).Offset(1)
Else
y = WorksheetFunction.CountA(Rows(Cell.Row)) - 2
z1 = Application.Match(Cell, Range("New!B:B"), 0)
z2 = WorksheetFunction.CountA(Sheets("New").Rows(z1))
Cell.Offset(, 1).Resize(, y).Copy Sheets("New").Cells(z1, z2 + 1)
End If
Next Cell
End Sub
Is anyone able to help?
Many thanks!