Hi Everyone
i m trying to do a For Each Statement,
for Ex: for each row it should paste some cells to another sheet, but it does the command only for the last row.
This is the Code:
Thanks
i m trying to do a For Each Statement,
for Ex: for each row it should paste some cells to another sheet, but it does the command only for the last row.
This is the Code:
Code:
Sub EnterIncome()
Dim rcrdRow As Long
Dim pstRow As Long
Dim shAccount As Worksheet
Dim shRecord As Worksheet
Dim accRow As Range
Dim cName As String, cDT
Dim cAccount, cAmount As Range
Set shRecord = Sheet2
pstRow = shRecord.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
cName = Sheet1.Range("C5")
cDT = Sheet1.Range("E7")
For Each accRow In Range("C10:C14")
If Len(accRow) > 0 Then
shRecord.Cells(pstRow, 1).Value = cDT
shRecord.Cells(pstRow, 2).Value = cName
shRecord.Cells(pstRow, 5).Value = accRow.Offset(0, 2)
shRecord.Cells(pstRow, 3).Value = accRow.Offset(0, 1)
shRecord.Cells(pstRow, 4).Value = accRow
End If
Next accRow
End Sub
Thanks