Array Dimensions Problem

Neutralizer

Board Regular
Joined
Sep 23, 2009
Messages
53
I have the following formula:

{=NumberOfArrayDimensions(IF(RR_Date_Check=Input_Prod_DATE,Input_Prod_RR_LABEL,""))}

RR_Date_Check is a named range for a single cell (i.e. $D$1)
Input_Prod_DATE is a named range (i.e. $A$1:$A$100)
Input_Prod_LABEL is a corresponding named range (i.e. $B$1:$B$100)

Can anyone explain to me why this is producing an array with more than 1 dimension? (i'm using a reliable VBA function to determine the number of dimensions in the array, it's coming back as 2...). To my mind this should produce a 1x100 array full of text strings (i.e. RR_Prod_Labels) or blanks cells (i.e. "")...where the hell is the second dimension coming from?

VBA function:
Code:
Function NumberOfArrayDimensions(Arr As Variant) As Long
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' NumberOfArrayDimensions
' This returns the number of dimensions of the array
' Arr. If Arr is not an array, the result is 0.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim LB As Long
Dim N As Long
On Error Resume Next
N = 1
Do Until Err.Number <> 0
LB = LBound(Arr, N)
N = N + 1
Loop
NumberOfArrayDimensions = N - 2
End Function
 
Last edited:
OK.
1D array to range works row wise
Code:
Range("A1:C1").Value = Array(1, 2, 3)
but not column wise
Code:
Range("A1:A3").Value = Array(1, 2, 3):Rem no good
Using INDEX to extract a row from a 2D array of values results in 1D array
Code:
MsgBox UBound(Application.Index(Range("A1:C3").Value, 3, 0), 2):Rem errors
Using INDEX to extract a column from a 2D array of values results in a 2D array
Code:
MsgBox UBound(Application.Index(Range("A1:C3").Value, 0, 3), 2):Rem 3

Using INDEX to extract a row (or column) of cells from a rectangular array of cells and then taking the values of that row (or column) results in a 2D array.
Code:
MsgBox UBound(Application.Index(Range("A1:C3").Cells, 2, 0).Value), 2):Rem 1
MsgBox UBound(Application.Index(Range("A1:C3").Cells, 0, 2).Value), 2):Rem 3
Which brings us full circle to the OP question.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,224,586
Messages
6,179,719
Members
452,939
Latest member
WCrawford

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