Juan Velasquez
asked on
Printing Debit and Credit using for loop
Hello,
I've written the code below to print the line items in the attached spreadsheet. It works fine and is printing the debit side of the amounts. I am now trying to print the credit side (basically, mutliplying the Trans Amount by -1). I'm trying to modify the code so that the credit will be displayed immediatly below the associated debit along with all the other linde data. I'm thinking that I need to use a for loop such that
For x = 1 to 2
if x = 1 then
'Print Debit
x = x + 1
elseif x = 2 then
'Print Credit
exit for
end if
next
I'm just having trouble placing the for loop in the right place.
I've written the code below to print the line items in the attached spreadsheet. It works fine and is printing the debit side of the amounts. I am now trying to print the credit side (basically, mutliplying the Trans Amount by -1). I'm trying to modify the code so that the credit will be displayed immediatly below the associated debit along with all the other linde data. I'm thinking that I need to use a for loop such that
For x = 1 to 2
if x = 1 then
'Print Debit
x = x + 1
elseif x = 2 then
'Print Credit
exit for
end if
next
I'm just having trouble placing the for loop in the right place.
Private Sub PopulateLineItems(wsSource As Worksheet, wsDestination As Worksheet)
' Comments: Used to populate line items in 8.9 upload report
' Params :
' Created : 06/22/12 10:39 JV
' Modified:
On Error GoTo PROC_ERR
'Populates line items
Dim rng As Range
Dim lngY As Long
Dim dblTransAmount As Double
Dim rngTran As Range
Dim strLineId As String
Dim x As Long
x = 1
'Print Debit
mRngHeaderLine(mlngNextRow, 1).Value = cstLineItem
mRngCurrencyCode(mlngNextRow, 1).Value = cstCurrencyCode
mRngLedger(mlngNextRow, 1).Value = cstLedger
mRngAffiliate(mlngNextRow, 1).Value = Mid(wsSource.Name, 6, 5)
mRngTransactionId(mlngNextRow, 1).Value = Mid(wsSource.Name, 11, 1)
Set mRgInterestAccruals = wsSource.Range("InterestAccruals")
mlngX = 1
For Each rng In wsSource.Range("MonthEnding")
If Format(rng, "mmddyyyy") = Format(gstrJournalDate, "mmddyyyy") Then '
dblTransAmount = CDbl(mRgInterestAccruals(mlngX, 1))
mRngLineId(mlngNextRow, 14).Value = dblTransAmount
mRngLineDescription(mlngNextRow, 1) = cstInterest
Exit For
End If
mlngX = mlngX + 1
Next
PROC_EXIT:
Exit Sub
PROC_ERR:
MsgBox Err.Description, vbCritical, "PopulateData.PopulateLineItems"
Resume PROC_EXIT
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.