Sub Reorg()
Dim ws As Worksheet
Dim headings As String
Dim supplier As String
Dim lastrow As Long
Dim nextrow As Long
Dim i As Long
Applic ation.ScreenUpdating = False
headings = "New Transaction,Date,Type,Bill#,Name,Source Account,Account,Class,Item,Qty,Price Each,Amount"
Set ws = Worksheets("Sheet2")
If ws.Range("A1") = vbNullString Then
ws.Range("A1").Resize(, Len(headings) - Len(Replace(headings, ",", vbNullString)) + 1).Value = Split(headings, ",")
nextrow = 2
Else
nextrow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
End If
With Worksheets("Sheet1")
lastrow = .Cells(.Rows.Count, "E").End(xlUp).Row
i = 1
For i = i To lastrow
Do Until .Cells(i, "C").Value = "Vendor :"
i = i + 1
Loop
supplier = .Cells(i, "D").Value
Do Until IsNumeric(.Cells(i, "E").Value) And .Cells(i, "E").Value <> vbNullString
i = i + 1
Loop
Do Until .Cells(i, "E").Value = vbNullString
nextrow = nextrow + 1
ws.Cells(nextrow, "A").Value = "YES"
ws.Cells(nextrow, "B").Value = Date
ws.Cells(nextrow, "C").Value = "Bill"
ws.Cells(nextrow, "D").Value = .Cells(i, "E").Value
ws.Cells(nextrow, "E").Value = supplier
ws.Cells(nextrow, "F").Value = "Account Payable"
ws.Cells(nextrow, "L").Value = .Cells(i, "N").Value
i = i + 1
Loop
Next i
End With
Application.ScreenUpdating = True
End Sub
Bookmarks