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
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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.
 
Upvote 0

Forum statistics

Threads
1,215,477
Messages
6,125,037
Members
449,205
Latest member
Eggy66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top