Sei sulla pagina 1di 5

'Copyright 2000 Alan Beban

Function Assign(InputRange, InputArray)


'This function facilitates the "direct" assignment
'of a range (or array) to a non-Variant() type of
'array. It will accept as the input "range" to be
'assigned a single-area multi-cell range or a 1-D
'or 2-D non-hierarchical array; and will accept as
'the input array, to which assignment is to be made,
'a dynamic array of a built-in type other than
'"Object()". It provides for a return ("Success")
'so that error trapping can more easily be
'provided in the calling procedure.
Sub ResizeArray(ByRef MyArray As Variant, _
ByVal new1 As Long, _
Optional ByVal new2 As Long = -1, _
Optional ByVal new3 As Long = -1)
'ReDim Preserve can be used to change the size of
'only the last dimension of an array while
'preserving its values; this Sub procedure, while
'preserving the values of the array that is passed
'to it, will increase the size of any or all of the
dimensions of a one-, two- or three-dimensional array.
'Its arguments are the array and its new dimensions.
Function MakeArray(ParamArray InputParameter()) As Variant
' This function will accept virtually any type of basic
' input, and return a one-dimensional "horizontal" array
' (0-based or 1-based in accordance with the last input
' argument), including all the elements of the input data.
' The function will accept arrays of arrays to two levels.
' It is called with, e.g., for a 0-based output array:
' arr = MakeArray(array1, range1, string1, arrayOfArrays, _
'
range2, value2, 0)
Function SubArray(InputArray, NewFirstRow, NewLastRow, _
NewFirstColumn, NewLastColumn)
'This function returns any "rectangular" sub array
'of a two-dimensional input array, as defined by
'the new first and last rows and columns.
Function RowVector(InputArray, RowNumber)
'This function returns an individual row
'vector from a one- or two-dimensional array
Function ColumnVector(InputArray, ColumnNumber)
'This function returns an individual column
'vector from a one- or two-dimensional array
Function ArrayCountIf(InputArray, SoughtValue, Optional Op, _

Optional MatchCase As Boolean = False, Optional dDate)


'This function counts the occurrences of a particular
'value or values, or instances of comparisons in an
'array (or range). To count empty strings the call is
'ArrayCountIf(myArray,""). To count empty blanks it is
'ArrayCountIf(myArray,"="). To count = signs it is
'ArrayCountIf(myArray,"=","="). The Function is case'sensitive if True is entered as the fourth (optional)
'argument; if it is case-sensitive, the comparisons
'are in accordance with Option Compare Binary; if not,
'then in accordance with Option Compare Text. The
'Function will not currently accept an array of sought values.
Function ArrayMatch(lookupValue, lookupArray, _
Optional Output = False, Optional RefStyle = 1, _
Optional CaseMatching As Boolean = False)
'Without an optional argument, this procedure outputs a
'two-column array that contains in each row the row index
'and column index of an occurrence of the lookup value
'in the lookup array (which, if it is a range, must be
'a single area); the entire array is the set of the
'row and column indices of all the occurrences of the
'lookup value. If "A" is entered as the first
'optional argument, and if the input lookup array is
'a worksheet range, the procedure outputs a one-column
'array of the cell addresses of all occurrences of the
'lookup value. The reference style of the addresses is
'determined by the optional fourth argument; absolute
'row and column references is the default, and an
'argument of 2, 3 or 4 assigns the same reference style
'as those arguments for the worksheet ADDRESS function.
'*IF THE LOOKUP VALUE DOES NOT OCCUR IN THE LOOKUP ARRAY*,
'and the function is not being called from the worksheet,
'then the function will return an unannounced error, so
'the calling code should provide for that. E.g., if the
'calling code is in a Sub procedure as x=ArrayMatch([whatever]),
'the call could be followed by If IsError(x) Then [do whatever
'should be done if no matches are found].
Function VLookups(lookupValue, lookupArray, ColumnNumber)
'This function acts somewhat like the built-in VLookup
'Function with exact matches, except that it returns an
'array of all the values corresponding to multiple
'occurrences of the sought value in the left hand column
'(i.e., the first column vector in the lookup array).
Function HLookups(lookupValue, lookupArray, RowNumber)
'This function is the analog of the VLookups Function
'documented above.
Function ArrayCount(InputArray)

'This function counts NOT the number of


'non-blank values in the array, but the
'number of available slots for values,
'whether the slots contain anything or not.
'It's similar to the Count Property (e.g.,
'Range("a1:c3").Count).
Function ArrayDimensions(InputArray)
'This function returns the number of dimensions
'of the input array
Function VLookupLeft(lookupValue, lookupArray As Range, _
returnValueColumn As Integer, _
Optional lookupValueColumn As Integer = -257)
'This function performs a simple lookup for values
'to the left (as well as to the right) of the
'lefthand column of the lookup array. And with 4th
'argument added, it allows any column of the
'lookupArray to be used rather than the lefthand
'column.
Function MatchingValues(indexArray, matchArray, matchValue)
'This function returns an array of the values in an
'array (indexArray) that match a specified value
'(matchValue) in another equal sized array (matchArray).
Function ArrayTranspose(InputArray)
'This function returns the transpose of
'the input array or range; it is designed
'to avoid the limitation on the number of
'array elements that the worksheet TRANSPOSE
'Function has.
Function ArrayReshape(InputArray, NumberRows, NumberColumns, _
Optional ByColumns As Integer = -1)
'This function returns a rectangular, NumberRows X NumberColumns,
'array containing the elements of the input array or range.
'Without the optional argument it fills the output array
'row by row; with the optional argument (i.e., 1), it fills
'the output array column by column
Function ArrayUniques(InputArray, _
Optional AsColumn As Integer = -1)
'This function returns an array of the
'unique values in an array or range. For a
'one-dimensional "horizontal" output, use
'only the first argument, the input array
'or range; for a two-dimensional single
'column output, enter 1 as the second
'argument.

Function RowsEqual(Row1, Row2)


'This function checks to see if two "rows"
'of an array or range are equal; it returns
'True if they are, False if they are not.
Function ColumnsEqual(Column1, Column2)
'This function for comparing columns
'is analogous to the RowsEquals function.
Function ScalarMult(InputArray, ScalarMultiplier As Single)
'This function returns the array resulting from
'multiplying each element of the input array by
'the scalar multiplier
Function ArrayAdd(Array1, Array2, Optional Add = True)
'This function returns an array in which the
'elements of the second input array have been
'added to or subtracted from those of the first
'input array. To add, omit the optional argument
'or insert "Add" (without the quotes) as the optional
'argument; to subtract, insert "subtract" (without
'the quotes) as the optional argument.
Function ConvertBase(InputArray, ResultingBase)
'This function converts an input array to
'a 0-based array or a 1-based array, in
'accordance with the ResultingBase argument
'(either 0 or 1). It accepts arrays with a
'base equal to the number of the ResultingBase
'argument, simply leaving them as is.
Function ArrayRowFilter1(InputArray, FilterColumn As Integer, _
FilterValue, Optional Op, Optional MatchCase As Boolean = False)
'This function returns an array of the elements in rows of an
'array in which the value in the specified Filter Column
'compares, as specified in the fourth argument, to the specified
'Filter Value; if the fourth argument is omitted, the comparison
'is equality. The filtering is case sensitive unless the fifth
'argument is entered as False. If the Function is called as
'case sensitive, the comparison is determined by Option Compare
'Binary; if not case sensitive, by Option Compare Text.
Function ArrayRowFilter2(InputArray, FilterColumn As Integer, _
FilterValue, Optional Op, Optional MatchCase As Boolean = False)
'This function is virtually identical to ArrayRowFilter1. It is
'provided to facilitate selecting the appropriate number of cells
'when calling multiple filters from the worksheet; the syntax
'is ArrayRowFilter2(ArrayRowFilter1(ArrayRowFilter1...)...)...)
Function ArrayColumnFilter(InputArray, FilterRow, FilterValue)
'This function for filtering columns is

'analogous to the original, unrevised ArrayRowFilter


Function ArrayAlternates(InputArray, _
'Optional Odds As Boolean = True,
'Optional RowOrientation As Boolean = True)
'This function returns every odd or even row or
'column, depending on the input arguments. For every
'odd row, the second argument is True (or omitted);
'for every even row, the second argument is False;
'for every odd column, the second argument is True
'(or omitted) and the third is False; for every even column,
'the second argument is False and the third is False.

Potrebbero piacerti anche