I am using Excel 2002 SP3 and am very new to VBA. I have the following bit of code that changes the current cell in the range to zero if the current cell is greater than zero, otherwise it is "supposed" to be populating the current cell with the value in the same row but 5 columns back (column G). However, my current code is selecting the correct column, but is returning the value for row 2 of that column. How to get the information that I need to get to the correct (current) row?
Range("L2").Select
' Range(Selection, Selection.End(xlDown)).Select
' Application.CutCopyMode = False
' Selection.Copy
'payoffs have an end scheduled balance of 0 so default value to beginning schd balance
For Each PayoffCellRng In Range(Selection, Selection.End(xlDown))
If PayoffCellRng.Value <> 0 Then
PayoffCellRng.Value = 0
Else
PayoffCellRng.Value = ActiveCell.Offset(0, -5).Value
End If
Next PayoffCellRng
Range("L2").Select
' Range(Selection, Selection.End(xlDown)).Select
' Application.CutCopyMode = False
' Selection.Copy
'payoffs have an end scheduled balance of 0 so default value to beginning schd balance
For Each PayoffCellRng In Range(Selection, Selection.End(xlDown))
If PayoffCellRng.Value <> 0 Then
PayoffCellRng.Value = 0
Else
PayoffCellRng.Value = ActiveCell.Offset(0, -5).Value
End If
Next PayoffCellRng