Results 1 to 4 of 4

Thread: error collecting, sorting data in Arrays in Excel

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    13

    error collecting, sorting data in Arrays in Excel

    Hi there,
    I'm a newbie with some prog exp but I inherited this code and can't get it to run -- seems like something with the contents of the arrays, or maybe i'm missing code to "close" the arrays, if such a thing is needed - -everything runs fine until the second to last line, when I try and create a new worksheet where I can dump all the data I've accumulated in arrays, in order to sort and filter it. (Gives me runtime error 9 - subscript out of range)
    The way this prog works - it has a wksheet with reports listed along with checkboxes - If a report is checked, prog will go to another column on that row and pick up the necessary columns it will need to look up in a datadump worksheet. It will go to that worksheet and place all records with "TRV"
    in a column and pick up 3 pieces of data in other colums and save the results to TRVsecurities(TRVcount) = myRow.
    Sorry for the long email -- any help would be greatly appreciated.
    BTW any help with getting rid of these Active.cell statements or better/easier design would greatly be appreciated.
    Fred

    VB Code:
    1. Sub runReport8(ByVal rowIndx As Integer)
    2.  
    3.     Workbooks("aegis_reporting.xls").Activate
    4.     Worksheets("Reports").Activate
    5.     Range("A" & rowIndx).Select
    6.    
    7.     Dim rowControl2 As Integer
    8.     Dim leftOffOn As Integer
    9.    
    10.     Dim myReportName As String
    11.     myReportName = ActiveCell.Value
    12.    
    13.     Dim mySheetName As String
    14.     Range("G" & rowIndx).Select
    15.     mySheetName = ActiveCell.Value
    16.    
    17.     Dim columnParameters As String
    18.     Dim colParamArray() As String
    19.     Range("H" & rowIndx).Select
    20.     columnParameters = ActiveCell.Value
    21.     colParamArray = Split(columnParameters, ",")
    22.     'B,C,J,P,Q
    23.     '0,1,2,3,4
    24.    
    25.     MsgBox columnParameters
    26.    
    27.     Worksheets(mySheetName).Activate
    28.     Range("B2").Select
    29.    
    30.     Dim lastRow As Integer
    31.    
    32.     ActiveCell.End(xlDown).Select
    33.     lastRow = ActiveCell.Row
    34.    
    35.     Range(colParamArray(0) & "2").Select
    36.    
    37.     Dim rowControl, mysteryRow As Integer
    38.     Dim USCPAcount, MMFcount, TRVcount As Integer
    39.    
    40.     Dim TRVsecurities(1000) As String
    41.     Dim myRow As String
    42.    
    43.     For rowControl = 2 To lastRow
    44.         mysteryRow = ActiveCell.Row
    45.        
    46.         If ActiveCell.Text = "TRV" Then
    47.            ' Range(colParamArray(2) & ActiveCell.Row).Value - _
    48.            ' Range(colParamArray(3) & ActiveCell.Row).Value
    49.            
    50.             myRow = ActiveCell.Value
    51.             Debug.Print myRow
    52.             TRVcount = TRVcount + 1
    53.             Range(colParamArray(1) & mysteryRow).Select
    54.             myRow = ActiveCell.Value
    55.             Debug.Print myRow
    56.             Range(colParamArray(2) & mysteryRow).Select
    57.             myRow = myRow & ":" & ActiveCell.Value
    58.             Debug.Print myRow
    59.             Range(colParamArray(3) & mysteryRow).Select
    60.             myRow = myRow & ":" & ActiveCell.Value
    61.             Debug.Print myRow
    62.             TRVsecurities(TRVcount) = myRow
    63.             Debug.Print myRow
    64.             Range(colParamArray(0) & mysteryRow).Select
    65.         End If
    66.    
    67.         ActiveCell.Offset(1, 0).Select
    68.     Next rowControl
    69.    
    70.     'START TRV block
    71.    
    72.     Workbooks("aegis_reporting.xls").Activate
    73. [COLOR=DarkGreen]    Worksheets(myReportName & "_Sort").Activate[/COLOR]
    74.     ' Gives me runtime error 9 - subscript out of range
    75.     Call clearSheet
    Last edited by si_the_geek; May 24th, 2006 at 08:01 PM. Reason: added vbcode tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width