Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

runtime error 9 ,subscript out of range 1

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
I have tried to create a loop that gives me the runtime error 9. What I am tring to do is loop through Cells A8 through A100. The cells in this range are client initials. This is a list of client closing dates, that the order of clients changes every month. Only some clients have adhocs that I have to run. So what I would like the loop to do when it sees certain client the adhoc for that client populates in Column P. So as an example a client with the initials SPN is in cell A8 that client has two adhocs called "HMA CPT Rpt, Accrual Rpts". I have tried three different types of loops and I keep on getting the subscript error. Any help is appreciated.

Tom

Code:
Sub SetAdhocReports()
'
' SetAdhocReports Macro

    Dim A()
    Dim P()
    Dim c As Variant

    For Each c In Worksheets("ClientProcessing").Range("A8:A100").Cells
        If c = "SPN" Then P(8) = "HMA CPT Rpt, Accrual Rpts"
    Next
End Sub
 
hi,
Code:
Sub SetAdhocReports()
'
' SetAdhocReports Macro

    Dim A()
    Dim P()
    Dim c As [b]RANGE[/b]

    For Each c In Worksheets("ClientProcessing").Range("A8:A100")
        If c[b].VALUE[/b] = "SPN" Then P([red][b]8[/b][/red]) = "HMA CPT Rpt, Accrual Rpts"
    Next
End Sub
How does array P get diminsion for element 8??? Check out ReDim.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Which line raises the error ?
My guess is P(8) is the culprit as P is not yet dimensioned.

What about this ?
If c = "SPN" Then c.Offset(0, 15) = "HMA CPT Rpt, Accrual Rpts"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top