'Trying to print or access value inside a multidimensional VBA array

'For the most part, I understand how arrays work but apparently not multidimensional ones in VBA. Below is a simple subroutine in which I want to debug.print/access the value E or S from the multi-dimensional array below. can someone explain? I suspect I am not declaring the array properly.

Sub car()

    ReDim carData(3, 21)

        carData(0, 0, 0, 0) = "ID" '
        carData(0, 1, 0, 0) = "UUID"
        carData(0, 2, 0, 0) = "Active" 
        carData(0, 3, 0, 0) = "Model Number" 
        carData(0, 4, 0, 0) = "bla bla" 
        carData(0, 5, 0, 0) = "bla bla"
       ' ... 
       ' pretend like I wrote this all the way out to 18...
       ' ...
        carData(0, 18, 0, 0) = ""
        carData(0, 18, 0, 1) = ""
        carData(0, 18, 0, 2) = ""
        carData(0, 18, 0, 3) = ""
        carData(0, 18, 1, 0) = "E" '<----- I want to access this value.
        carData(0, 18, 1, 1) = ""
        carData(0, 18, 1, 2) = "S"
        carData(0, 18, 1, 3) = ""
        
        carData(0, 19, 0, 0) = ""
        carData(0, 20, 0, 0) = ""
    
        Debug.Print carData(0, 19, 1, 0)
    
End Sub


Solution 1:[1]

I did not declare the correct dimension level and the array was named differently in certain places. Anyways I'll leave the answer below for anyone who might experience the same issue.

Sub car()

    ReDim carData(3, 22, 1, 3)

        carData(0, 0, 0, 0) = "ID" '
        carData(0, 1, 0, 0) = "UUID"
        carData(0, 2, 0, 0) = "Active" 
        carData(0, 3, 0, 0) = "Model Number" 
        carData(0, 4, 0, 0) = "bla bla" 
        carData(0, 5, 0, 0) = "bla bla"
       ' ... 
       ' pretend like I wrote this all the way out to 18...
       ' ...
        carData(0, 18, 0, 0) = ""
        carData(0, 18, 0, 1) = ""
        carData(0, 18, 0, 2) = ""
        carData(0, 18, 0, 3) = ""
        carData(0, 18, 1, 0) = "E" '<----- I want to access this value.
        carData(0, 18, 1, 1) = ""
        carData(0, 18, 1, 2) = "S"
        carData(0, 18, 1, 3) = ""
        
        carData(0, 19, 0, 0) = ""
        carData(0, 20, 0, 0) = ""
    
        Debug.Print carData(0, 18, 1, 0)
    
End Sub

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1