Object Variable or With Block Variable Error

Hap

Well-known Member
Joined
Jul 20, 2005
Messages
647
I have an array define with:

Dim newPoints() As PolyPoint

PolyPoint is a user defined type that stores the X and Y values of a point in the cartesian plane.

I Redimension the the array with:

ReDim newPoints(1 To 2 * UBound(anotherArray))

I add to the array with a loop as follows:

Count = 1
For i = 1 To UBound(anotherArray)
For j = 1 To aCollection.Count - 1
newY = anotherValue
Set newPoints(Count) = New PolyPoint
newPoints(Count).X = xValue
newPoints(Count).Y = newY
Count = Count + 1
Next j
Next i


After this operation I get the Object Variable etc. Error when I try the use the values in newPoints:

divList = divList + ", " & newPoints(1).X

I would appreciate any help to get past this error. I think I might have set my array incorrectly but I am not sure.

Thanks
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Hap

Well-known Member
Joined
Jul 20, 2005
Messages
647
When the code runs to the divList line of code I checked the locals window and the array values are all listed as "Nothing". I don't know if this would throw the error when I am trying to recall the values but I am now wondering why the values are not being attached to the array.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,109
Messages
5,570,246
Members
412,312
Latest member
linister
Top