Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a string array, declared by:
Dim HRColHdrs(3) As Variant I explicitly define the strings, then pass them to a function, as "ColHdrs" shown below. Private Sub HdrChk(ByVal ShtName As String, ByRef ColHdrs As Variant) Dim i, n As Long Debug.Print (Len(ColHdrs)) End Sub Within this function, I would like to determine how many elements are in this array that was passed. However, when I use the len() function, I get Type mismatch error. Things I have tried: -Declaring "HRColHdrs" as an array of type String in the main function (no change in error) -Declaring the "ColHdrs" as a variable of type String or Object rather than Variant -Declaring "ColHdrs" as a ByVal variable -Using the ColHdrs.Length method (error changes to "Object required") -I used debug.print to make sure that I can read the individual elements of ColHdrs in the subroutine - I can. Oh, if only every language handled arrays like Matlab scripting :-/. The only workaround I can think of is to step through a For loop and address each element of the array directly, until it throws a subscript error, then use the error handler to extract from the loop. EggHeadCafe - Software Developer Portal of Choice ASP.NET 2.0: Using the Menu Control http://www.eggheadcafe.com/tutorials...ng-the-me.aspx |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Assign Range passed to fuction to an array | Excel Programming | |||
Array problem: Key words-Variant Array, single-element, type mismatch error | Excel Programming | |||
Array problem: Key words-Variant Array, single-element, type mismatch error | Excel Programming | |||
ReDim Object array as parameter of Variant array | Excel Programming | |||
variant array containing cel adresses convert to actual ranges-array | Excel Programming |