ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   log based on cell values (https://www.excelbanter.com/excel-programming/408289-log-based-cell-values.html)

bearly_competent

log based on cell values
 
Hi, all

Can someone explain to me why this code doesn't work? I get a 424 error and
the debugger points to the line I indicate below:

Sub volatility()
Sheets("HistoricalVolatility").Select
z = 2 + 1
vol = 0
Count = 0
Do While Cells(z, 7) < ""
vol = vol + Log(Cells(z, 7).Value) / Log(cell.Offset(-1, 0).Value) '
here's the prob
Count = Count + 1
z = z + 1
vol = vol / Count
Loop
Sheets("Options").Range("B9").Value = vol
End Sub

cht13er

log based on cell values
 
On Mar 25, 12:55*pm, bearly_competent
wrote:
Hi, all

Can someone explain to me why this code doesn't work? I get a 424 error and
the debugger points to the line I indicate below:

Sub volatility()
Sheets("HistoricalVolatility").Select
z = 2 + 1
vol = 0
Count = 0
Do While Cells(z, 7) < ""
* * vol = vol + Log(Cells(z, 7).Value) / Log(cell.Offset(-1, 0).Value) *'
here's the prob
* * Count = Count + 1
* * z = z + 1
* * vol = vol / Count
Loop
Sheets("Options").Range("B9").Value = vol
End Sub


"cell" should be "cells" it looks like. Is that it?

Chris

bearly_competent[_2_]

log based on cell values
 
if I use "cells", I get the error msg "sub or func not defined"

"cht13er" wrote:

On Mar 25, 12:55 pm, bearly_competent
wrote:
Hi, all

Can someone explain to me why this code doesn't work? I get a 424 error and
the debugger points to the line I indicate below:

Sub volatility()
Sheets("HistoricalVolatility").Select
z = 2 + 1
vol = 0
Count = 0
Do While Cells(z, 7) < ""
vol = vol + Log(Cells(z, 7).Value) / Log(cell.Offset(-1, 0).Value) '
here's the prob
Count = Count + 1
z = z + 1
vol = vol / Count
Loop
Sheets("Options").Range("B9").Value = vol
End Sub


"cell" should be "cells" it looks like. Is that it?

Chris


cht13er

log based on cell values
 
On Mar 25, 1:24*pm, bearly_competent
wrote:
if I use "cells", I get the error msg "sub or func not defined"



"cht13er" wrote:
On Mar 25, 12:55 pm, bearly_competent
wrote:
Hi, all


Can someone explain to me why this code doesn't work? I get a 424 error and
the debugger points to the line I indicate below:


Sub volatility()
Sheets("HistoricalVolatility").Select
z = 2 + 1
vol = 0
Count = 0
Do While Cells(z, 7) < ""
* * vol = vol + Log(Cells(z, 7).Value) / Log(cell.Offset(-1, 0).Value) *'
here's the prob
* * Count = Count + 1
* * z = z + 1
* * vol = vol / Count
Loop
Sheets("Options").Range("B9").Value = vol
End Sub


"cell" should be "cells" it looks like. Is that it?


Chris- Hide quoted text -


- Show quoted text -


Then try using this:
vol = vol + Log(Cells(z, 7).Value) / Log(Cells(z-1,7).Value)

I think that will work .. post again if it doesn't!

Chris


All times are GMT +1. The time now is 08:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com