Hi,
I am running a report and get this error
Run-time error 1004: Application-defined or object-defined error
Takes me to the line .Offset(i, 4).Value = .Offset(i, 3).Value - .Offset(i, 2).Value in my VBA function that is
Public Sub GetMxVolume()
Dim connstr As String
Dim sqlStr As String
Dim conn As connect
Set conn = New connect
Dim i As Integer
Dim ticker As String
Application.DisplayAlerts = False
conn.connect_mx
i = 1
With Range("avgStart")
Do While .Offset(i) <> ""
ticker = .Offset(i).Value
sqlStr = "select ISNULL(SUM(marketvolume),0) from mxmarketparticipation where ticker = '" & ticker & "' " & _
"and loaddate >= '" & startDate & "' and loaddate <= '" & endDate & "' and expirycutoff is null"
conn.m_rds.Open sqlStr, conn.m_conn
.Offset(i, 3).CopyFromRecordset conn.m_rds
.Offset(i, 4).Value = .Offset(i, 3).Value - .Offset(i, 2).Value
conn.m_rds.Close
i = i + 1
Loop
End With
Application.DisplayAlerts = True
End Sub
Firstly, how do I start debugging based off of that error? It seems super general. Secondly, how can you get an error from Offsets? Isn't it just moving around in the cells and subtracting?
Where should I look for the source of the error? Thanks.
Bookmarks