PDA

View Full Version : LN formula



cherylinn
11-30-2012, 03:30 AM
I have about 200 rows in column C and i need to calculate all the value in column d with the following formula , LN("row 1 in column c" / "row 2 in column c") . Thus the result will return 199 rows in column D. How to use VBA code to do that ?

patel
11-30-2012, 03:47 AM
why vba and not formulas ?
attach a sample file with comments

cherylinn
11-30-2012, 05:47 AM
why vba and not formulas ?
attach a sample file with comments

patel
12-01-2012, 12:52 AM
Sub a()
LR = Cells(Rows.Count, "A").End(xlUp).Row
For j = 3 To LR
Cells(j, 4).Value = WorksheetFunction.Ln(Cells(j, 1).Value / Cells(j - 1, 1).Value)
Next
End Sub

cherylinn
12-01-2012, 01:37 AM
Sub a()
LR = Cells(Rows.Count, "A").End(xlUp).Row
For j = 3 To LR
Cells(j, 4).Value = WorksheetFunction.Ln(Cells(j, 1).Value / Cells(j - 1, 1).Value)
Next
End Sub

Thanks! I managed to solve it! :bow: