Link to home
Start Free TrialLog in
Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on

Debug.Print members of an array

I inherited some code that populates an array, but I don't think it is doing waht it should - how do I debug.print the members of an array?  Attached is the module, but where would I put the Debug.Print so I can see each member as it is added to the array?
Sub fillPortfolioURLStringArray(ByVal s_namedRange As String)
' Grab all the URL strings in the named range (s_namedRange) passed, and store them in
' an array for use in the main subprocedure.
Dim wkb_currentWorkbook     As Workbook     ' This current application workbook with controls, URLs and dashboard.
Dim intCounter              As Integer      ' Counter in the array population loop
Dim intValidRangeMembers    As Integer      ' Capture the distinct number of validated members in the array so we can dimension
Dim intRowAddress           As Integer      ' Refer to the row number of any non-blank cell storing a URL in the
                                            ' appropriate named range.
Dim intIndex                As Integer      ' Used to populate the array index
Dim strCheckString          As String       ' Capture to check for string anomalies
    'Activate the first range to pump into an array
    ' Determine how many cells are populated in our total range and dimension our array index to that number.
    ' (Note - this will work because it is a one dimension array and would not if the array were multi-dimensioned)
    intIndex = Range(s_namedRange).Cells.Count
    ReDim s_blackRockURL(intIndex)
    ' Initialize our counter variables
    intCounter = 1       ' Simple counter
    intRowAddress = 1    ' Represents the row address for the URL cell. If a range cell is populated by
                        ' an empty string, we want to pass it by, not store it, and continue through
                        ' the range array.
    Do Until intCounter > intIndex
        ' If the URL in the range is not a zero-length string, then save it as a member of the array.
        ' If so, advance to the next range cell and try again.
        ' Let's make sure the cell storing the URL is populated.
        ' If not, let's advance but not increment our array members.
        strCheckString = Range(s_namedRange).Cells(intValidRangeMembers, 1).Value
                If strCheckString <> "" Then
                    s_blackRockURL(intCounter) = Range(s_namedRange).Cells(intRowAddress, 1)
                    'Tally of the number of validated array members in the range.
                    intValidRangeMembers = intValidRangeMembers + 1
                    intRowAddress = intRowAddress + 1
                    intCounter = intCounter + 1
                        intRowAddress = intRowAddress + 1
                End If
    'Since we now have a tally of how many members belong to the portfolio type passed in,
    'redimension our array to correspond to only those members.
    ReDim Preserve s_blackRockURL(intValidRangeMembers)
    If Err.Number <> 0 Then
        wksSpec.Protect Password:=s_PSWD    ' Reprotect Settings worksheet
        Set wkb_currentWorkbook = Nothing   ' Tidy up
        Call SlowDown
     End If
End Sub

Open in new window

Avatar of SiddharthRout
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sandra Smith


Both worked and as they actually suited different problems and amounts of data, I am going to split.  Thank you.