Forum

Verify Array Values
 
Notifications
Clear all

Verify Array Values

2 Posts
2 Users
0 Reactions
75 Views
(@dmdavala)
Posts: 28
Eminent Member
Topic starter
 

I have the following VBA code.  My intent was to load the named range, "UP84Male" into the array "ArrayMortality"  I want to make sure the values are in the array. The range UP84Male is one column and 121 rows.

Public Sub Mortality()

Dim ArrayMortality As Variant

ArrayMortality = Range("UP84Male").Value

For i = 1 To 120
Debug.Print ArrayMortality(i)
Next i

End Sub

 

It bombs on the Debug.Print line.

 
Posted : 25/11/2020 4:59 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi David,

This actually creates a 2 dimensional array- the quirks of VBA!

To access the contents you need

Debug.Print ArrayMortality(i, 1)

You can also see the contents of the array in the Locals Window in your VBA Editor.

Regards

Phil

 
Posted : 25/11/2020 7:10 pm
Share: