records on multiple rows combined to single row

ltuckercpa

New Member
Joined
Feb 15, 2006
Messages
1
I have data from an outside source where the record is on multiple rows in multiple columns. I want to combine it so all data related to record 1 is on a single row with multiple columns and data from record 2 on the row below it, etc.

VENDOR TERMS AMT
ZIP CONTACT

vendorA Net30 $400
78753 Joe
vendorB Net15 $1000
78124 Jane
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Welcome to the board!
Try this:
Code:
Sub SplitVendorData()
  Dim L As Long, r As Long
  Dim DataOld As Range, DataNew As Range
  
  ' adjust next line to suit your data range
  Set DataOld = ActiveSheet.Range("A4").CurrentRegion
  
  Sheets.Add After:=Sheets(Sheets.Count)
  ActiveSheet.Name = "NewData " & Format(Now, "mmddyy hmmss")
  Set DataNew = ActiveSheet.Range("A1")
  With DataNew
    .Cells(1, 1) = "VENDOR"
    .Cells(1, 2) = "TERMS"
    .Cells(1, 3) = "AMT"
    .Cells(1, 4) = "ZIP"
    .Cells(1, 5) = "CONTACT"
  End With
  L = 2
  For r = 1 To DataOld.Rows.Count
    If WorksheetFunction.IsOdd(r) Then
      With DataNew
        .Cells(L, 1) = DataOld.Cells(r, 1)
        .Cells(L, 2) = DataOld.Cells(r, 2)
        .Cells(L, 3) = DataOld.Cells(r, 3)
      End With
    Else
      With DataNew
        .Cells(L, 4) = DataOld.Cells(r, 1)
        .Cells(L, 5) = DataOld.Cells(r, 2)
      End With
      L = L + 1
    End If
  Next r
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,408
Members
452,912
Latest member
alicemil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top