Macro Help

C

Curtis

I am very new to Macro's but am hoping you can simplify your response

I have a sheet that contains certain data types in specific columns

For example

Column A = Date
B= Name
C=Description
D=Cheque#
E= Account # (Debits)
F = Debit amount
G = Account # (Credits)
H= Credit Amount


I need to write a Marco that will look at this source sheet row by row and
transfer the information to a different sheet with predefined columns

Results Sheet

Column D = Account# (from Columns E and G above)
Column E = Amount (from columns F and H above (Note: Debits are positive,
but Credits need to be converted to a negative number)
Column J = Concantenate Column B and C from source sheet
Column K = Cheque #

Hoping you can help
 
J

Jacob Skaria

Try

Sub CopyRowstoDiffSheet()

Dim ws1 As Worksheet, ws2 As Worksheet
Dim lngRow As Long, lngTRow As Long

Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")

For lngRow = 1 To ws1.Cells(Rows.Count, "A").End(xlUp).Row
lngTRow = ws2.Cells(Rows.Count, "A").End(xlUp).Row + 1
ws2.Range("D" & lngTRow) = ws1.Range("E" & lngRow) & _
ws1.Range("G" & lngRow)
ws2.Range("E" & lngTRow) = ws1.Range("F" & lngRow) - _
ws1.Range("H" & lngRow)
ws2.Range("J" & lngTRow) = ws1.Range("B" & lngRow) & " " & _
ws1.Range("C" & lngRow)
ws2.Range("K" & lngTRow) = ws1.Range("D" & lngRow)
Next

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