Subscript 9 error, VBA Array, shorthand

Certified

Board Regular
Joined
Jan 24, 2012
Messages
189
Can anyone tell me why I am getting a subscript 9 error.

The error is at the line highlighted in red.

Code:
Sub Create_arrays()

Debug.Print "Creating the Arrays"

   Dim gemsDimension As Integer
   Dim lr As Integer
   Dim lc As Integer
   Dim number As Integer
   Dim col As Integer
   Dim r0w As Integer
   Dim sh33t As String
   Dim tempArray() As Variant
   Dim arrayData() As Variant
   
   
   arrayData = Array(Array("voting array", 1, 1, "VotingCopy", 0, "votingArray"), Array("capital array", 1, 1, "Capital", 0), _
   Array("gems array", 1, 1, "gems", 2), Array("Equity Array", 1, 1, "equitY", 0), Array("PickupArray", 1, 1, "pickUP", 0), _
   Array("bpc array", 1, 1, "bpc", 0), Array("Commets Array", 2, 1, "Comments", 1), Array("Create prelim array", 1, 1, "preliM", 0), _
   Array("Memo Array", 0, 0, 0), Array("sch 6", 0, 0, 0))
     
    For number = LBound(arrayData) To UBound(arrayData)
    
        [COLOR=#ff0000][B]col = arrayData(number, 2)[/B][/COLOR]
        r0w = arrayData(number, 3)
        sh33t = arrayData(number, 4)
        tempArray = arrayData(number, 6)
    
        colnm = col: rowNum = r0w
        Sheets(sh33t).Activate
        lr = wColLastRow(colnm)
        lc = wRowLastColNum(rowNum) + 1
        tempArray = getTheArray(rowNum, colnm, lr, lc)
        
        lr = 0
        lc = 0
        
    Next number
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Because you assigned Array functions within an overall Array function, you have to address the members of arrayData differently. For the red highlighted line of code above, it needs to read this way...

col = arrayData(number)(2)

and you would do similarly for the other arrayData references.
 
Upvote 0
Thank you!


Because you assigned Array functions within an overall Array function, you have to address the members of arrayData differently. For the red highlighted line of code above, it needs to read this way...

col = arrayData(number)(2)

and you would do similarly for the other arrayData references.
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,306
Members
449,079
Latest member
juggernaut24

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