Range22DimArray

Imports a range into 2-dimension array.
Returns the array, providing range, sheet and workbook as string, just how I usually do with most of my functions.
Can import values or formulas

CodeFunctionName
What is this?

Public

Tested

Original Work
Function Range22DimArray(sRange, Optional Value1_Fx2 = 1, Optional Shee ="This", Optional WK ="This")
    ' Returns a 2-dimension array having values (or formulas) of passed range
    '
    Dim Arr2D()
    if wb="This" then wb=thisworkbook.name
    if wb="Active" then wb=activeworkbook.name
    if shee="This" then shee=activesheet.name
    if shee="Active" then shee=activesheet.name
    Redim Preserve Arr2D(Range(sRange).Rows.Count, Range(sRange).Columns.Count)
    For I = 1 To Range(sRange).Rows.Count
        For J = 1 to Range(sRange).Columns.Count
            If Value1_Fx2 = 1 Then
                Arr2D(I, J) = workbooks(WK).Worksheets(Shee).Range(sRange).Cells(I,J).Value
            ElseIf Value1_fx2 = 2 Then
                Arr2D(I, J) = workbooks(WK).Worksheets(Shee).Range(sRange).Cells(I,J).Formula
            End If
        Next
    Next
    Range22DimArray = Arr2D
End Function

sRange, Optional Value1_Fx2 = 1, Optional Shee ="This", Optional WK ="This"

Views 153

Downloads 105

CodeID
DB ID