Av8tordude
Well-known Member
- Joined
- Oct 13, 2007
- Messages
- 1,075
- Office Version
- 2019
- Platform
- Windows
I tried to write a code to loop through each row, but it only outputs for the last row.
VBA Code:
Sub vba_loop_range()
Dim c As Range, LRow As Long
LRow = Application.Max(7, Range("A" & Rows.Count).End(xlUp).Row)
For Each c In Range("A" & LRow)
If c.Offset(0, 10) = "" Then
' Range("M" & ActiveCell.Row) = StockQuote(c.Value)
Range("M" & ActiveCell.Row) = LastOptionPrice(Range("A" & ActiveCell.Row) & Format(Range("E" & ActiveCell.Row), "yymmdd") & Left(Split(Range("C" & ActiveCell.Row), "-")(1), 1) & Format(Range("d" & ActiveCell.Row) * 1000, "00000000"))
Range("O" & ActiveCell.Row) = WorksheetFunction.Sum(Replace(Range("G" & ActiveCell.Row), "*", "") * Range("M" & ActiveCell.Row) * 100 - Range("I" & ActiveCell.Row))
Range("Q" & ActiveCell.Row) = WorksheetFunction.Sum(Range("O" & ActiveCell.Row) - Range("J" & ActiveCell.Row))
Range("R" & ActiveCell.Row) = Range("Q" & ActiveCell.Row) / Range("J" & ActiveCell.Row)
End If
Next c
End Sub