I have run into some weird behavior in the immediate window when querying values of some stopped code. mycell is dimmed as a range, and row is a long integer.
I don't know if I am running out of memory (task manager has excel at 432 MB) and excel is throwing random errors or if there truly is a difference between mycell(row) and mycell.offset(row). If I am running out of memory then I need to find a way to read less data in, but I suspect the problem is something else.
----
Update
I changed the code to use offset, and it ran a tiny bit further, but still died on an overflow error. I see that Mycell.Offset(row).value=<overflow>.
How can simply quering the valye of a cell cause an overflow? Here's the code:
This is frustrating and I don't know the value of a cell in VBA could overflow, when I can see the value clear as day in Excel. The one funky thing is that Excel VBA sees this as a date, but in fact the value is a number, or a currency to be more specific.</overflow>
Code:
[COLOR=#574123]? mycell(row)[/COLOR]
[COLOR=#574123]'results in pop up window, overflow, run time error 6[/COLOR]
[COLOR=#574123]? mycell.Offset(row)[/COLOR]
[COLOR=#574123]3/10/1903 9:10:57 AM [/COLOR]
[COLOR=#574123]? row[/COLOR]
[COLOR=#574123]5148
[/COLOR]? vartype(row)
3
? vartype(mycell(row))
9
? vartype(mycell)
8
I don't know if I am running out of memory (task manager has excel at 432 MB) and excel is throwing random errors or if there truly is a difference between mycell(row) and mycell.offset(row). If I am running out of memory then I need to find a way to read less data in, but I suspect the problem is something else.
----
Update
I changed the code to use offset, and it ran a tiny bit further, but still died on an overflow error. I see that Mycell.Offset(row).value=<overflow>.
How can simply quering the valye of a cell cause an overflow? Here's the code:
Code:
For Each Key In Header
Row = 2
Col = Col + 1
RLCarray(1, Col) = Key
Set MyCell = RLCSheet.Cells.Find(Key, lookat:=xlWhole)
If Not (MyCell Is Nothing) Then
Do
If IsNumeric(MyCell(Row)) Then
RLCarray(Row, Col) = Round(MyCell.Offset(Row).Value, 2)
Else
RLCarray(Row, Col) = MyCell.Offset(Row).Value
End If
Row = Row + 1
Loop Until Row > UBound(RLCarray)
Else
MsgBox ("Missing Header: " & Key & Chr(13) & "stopping.")
Stop
End If
Update = Update + 1
StatusWindow.Status.Caption = "Reading RLC data into array (" & Format(Update / UBound(Header), "##%") & ")"
DoEvents
Next
Last edited: