Public Sub DupeAndMorphRows()
' Config
VendorCol = 1
FirstCol = 1
LastCol = 14
AccCol = 8
DebCol = 10
CrdCol = 11
' Verify input sheet is active
msg = "Before running input sheet must be activeSheet !"
resp = MsgBox(msg, vbExclamation + vbOKCancel, "Confirm Input Sheet Active")
If Not resp = vbOK Then Exit Sub
' Determine bottom row based on Vendor
BotRow = Cells(Cells(1, VendorCol).EntireColumn.Cells.Count, VendorCol).End(xlUp).Row
' make copy of input sheet
ActiveSheet.Copy Before:=Sheets(1)
For CurrRow = BotRow To 2 Step -1
' Dupe Rows
Rows(CurrRow & ":" & CurrRow).Copy
Rows(CurrRow & ":" & CurrRow + 1).Insert Shift:=xlDown
OrigDebValue = Cells(CurrRow, DebCol).Value
For NewRow = 1 To 3
' Determine Values base on Row
Select Case NewRow
Case 1
accVal = "5300-FAT1"
debVal = OrigDebValue
crdVal = 0
Case 2
accVal = "5320"
debVal = 0
crdVal = OrigDebValue * 0.02
Case 3
accVal = "2100"
debVal = 0
crdVal = OrigDebValue * 0.98
End Select
'Morph Values
TargRow = CurrRow - 1 + NewRow
Cells(TargRow, AccCol).Value = accVal
Cells(TargRow, DebCol).Value = debVal
Cells(TargRow, CrdCol).Value = crdVal
Next NewRow
Next CurrRow
' Clean up & format
Application.CutCopyMode = False
Columns("K:K").NumberFormat = "$#,##0.00"
Columns("A:B").Delete
End Sub
Bookmarks