Increment array for debits and credits

M

MarcB

Hello,

I get a download with text reference in column A and values in column
B.
I'm trying to take each line and write the debit and credit entries to
a new workbsheet ("upload").
Here is the data:
A B
10002 10
10003 1
10004 -5
10005 6
10006 7
10007 9
Here is what the end product should look like:-
A B C
141000 40 10
151000 50 10
141000 40 1
151000 50 1
151000 50 -5
141000 40 -5
141000 40 6
151000 50 6
141000 40 7
151000 50 7
141000 40 9
151000 50 9

I've written what I think the code should look like, but I'm stuck in
writing the 2 arrays to be incremental on the final worksheet. Can you
please help.

Thanks,

Marc
Sub demo()

On Error Resume Next
Dim rngcell As Range

Dim acc_no As String
Dim amount As Currency
Dim debcred1 As String
Dim debcred2 As String
Dim opbal As Currency
Dim rngArr1 As Variant
Dim rngArr2 As Variant

Sheets("Settlements").Activate
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set Checkrange = Range("A2:A" & lastRow)

For Each rngcell In Checkrange

If rngcell = "SETF" Then

opball = rngcell.Offset(0, 2)
If opball > 0 Then
debcred1 = 40
debcred2 = 50
acc_no = 141000
Else
debcred1 = 50
debcred2 = 40
acc_no = 151000
End If

amount = Round(opball, 2)
'*********************************
'This is where I'm stuck


rngArr1 = Array(acc_no, debcred1, amount)
rngArr2 = Array(acc_no, debcred2, amount)
'*********************************
End If

Next rngcell

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top